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),然后重新安装依赖项。

二、总结

简洁、高效、易用!

相关推荐
马剑威(威哥爱编程)7 小时前
鸿蒙6开发中,UI相关应用崩溃常见问题与解决方案
ui·华为·harmonyos
ITVV10 小时前
元数据 Unity Catalog v0.3.0 UI
ui·元数据
袅沫1 天前
Element-UI 番外表格组件
javascript·vue.js·ui
百锦再2 天前
[特殊字符] HBuilder uni-app UI 组件库全方位对比
android·java·开发语言·ui·rust·uni-app·go
lqj_本人3 天前
鸿蒙与Qt的双线程模型:主线程与UI线程的博弈
qt·ui·harmonyos
南华3 天前
Visual Studio 2022 加载解决方案缓慢
ui
lqj_本人3 天前
鸿蒙原生与Qt混合开发:UI集成与事件处理
qt·ui·harmonyos
Irene19914 天前
Element UI 及其 Vue 3 版本 Element Plus 发展现状
前端·vue.js·ui
周周爱喝粥呀4 天前
UI设计原则和Nielsen 的 10 条可用性原则
前端·ui
大雷神4 天前
MateChat+ DevUI 电商后台管理系统中集成 AI 聊天助手功能
人工智能·ui