vue2.0版本引入Element-ui问题解决

作者:fyupeng

技术专栏:☞ https://github.com/fyupeng

项目地址:☞ https://github.com/fyupeng/distributed-blog-system-api


留给读者
使用版本:
vue:2.6.14
element-ui:2.15.14

一、问题及解决

1、安装后组件没有生效,报错:

shell 复制代码
`main.js:74 [Vue warn]: Property or method "__v_isRef" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
  • 解决方案(已验证):
shell 复制代码
npm i element-ui -S

全局引入,介意启动项目太慢选择局部引入:

js 复制代码
import Vue from 'vue'

import ElementUI from 'element-ui'; // ui组件
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);


import App from './App.vue'
....

// 放最后面,只能有一个 Vue 实例
new Vue({
  el: '#app', // 指定挂载点
  router, // 注入路由
  store, // 注入 Vuex store
  render: h => h(App) // 渲染 App 组件作为根组件
});

无需配置 CDN link标签就不配置,我就是配置后导致失效的。

2、遇到组件引入后,比如<el-input> 报错:

shell 复制代码
[Vue warn]: Property or method "__v_isRef" is not defined on the instance but referenced during render.
  • 解决方案(已验证):清理和重建项目:删除 node_modules 文件夹和任何锁文件(如 yarn.lock 或 package-lock.json),然后重新安装依赖项。

二、总结

简洁、高效、易用!

相关推荐
全栈若城1 小时前
31.Harmonyos Next仿uv-ui 组件NumberBox 步进器组件异步操作处理
ui·uv·harmonyos next
前期后期2 小时前
Android Compose是如何使用什么架构,多个Activity?还是Fragment?compose的ui又是如何卸载和挂载的呢?
android·ui·架构·kotlin
全栈若城11 小时前
27. Harmonyos Next仿uv-ui 组件NumberBox 步进器组件禁用状态
ui·uv·harmonyos next
全栈若城11 小时前
11 【HarmonyOS NEXT】 仿uv-ui组件开发之Avatar组件深度剖析(二)
ubuntu·ui·uv·harmonyos next
小怪兽长大啦11 小时前
【UI自动化测试思路】测试用例配置
服务器·ui·测试用例
tmacfrank15 小时前
Compose 实践与探索一 —— 关键知识与概念详解
android·ui·kotlin·android jetpack
tmacfrank17 小时前
Compose 实践与探索二 —— 状态订阅与自动更新1
android·ui·kotlin·android jetpack
qq_白羊座18 小时前
UI自动化:Selenium常规的页面元素定位方法
selenium·ui·自动化
m0_7482552619 小时前
Spring Boot 3.x 引入springdoc-openapi (内置Swagger UI、webmvc-api)
spring boot·后端·ui
前端 贾公子20 小时前
Vue.js 3 的设计思路:从声明式UI到高效渲染机制
vue.js·flutter·ui