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

二、总结

简洁、高效、易用!

相关推荐
图扑软件6 小时前
下篇・换墨|主题/多语言/移动端,一套组件全覆盖
前端·javascript·ui·性能优化·数据可视化
object not found2 天前
从 Page Design 到 System Design:我对 UI/UX 的一次认知变化
ui·ux
xy34532 天前
Axure9.0中继器遮罩实现方法
前端·ui·html·axure·原型·产品设计
晴天162 天前
Ant Design UI 库核心原理与应用
ui
玫瑰互动GEO2 天前
腾讯AnswerBit(GEO优化监测平台)技术拆解:UI自动化如何采集真实AI回答
大数据·人工智能·ui·ai·自动化·geo优化
摸鱼仙人~2 天前
Qwen-Code ACP与AG-UI协议深度解析:区别、场景与实战报文对比
ui
图扑软件3 天前
中篇・运笔|统一 DataModel 底座,HT UI 组件万物同源
javascript·低代码·ui·性能优化·数据可视化
l1m0_3 天前
智能电动自行车管理后台实战:AI生成页面与React组件化技巧
前端·react.js·ui·ai·设计
~远在太平洋~3 天前
06-鸿蒙系统 uitest UI 自动化指南
ui·自动化·harmonyos
兰亭妙微UI设计公司3 天前
兰亭妙微QT界面开发:设计系统侧边导航组件:告别混乱,实现高效协同
ui