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

二、总结

简洁、高效、易用!

相关推荐
Avalon7121 天前
Unity3D响应式渲染UI框架UniVue
游戏·ui·unity·c#·游戏引擎
qq_454245031 天前
从 UI 操作到环境交互:一种通用元命令自动化协议的设计与意义
人工智能·ui·自动化·交互
格林威1 天前
工业视觉检测:提供可视化UI调试工具的实现方式是什么?
开发语言·人工智能·数码相机·ui·计算机视觉·视觉检测·工业相机
ZC跨境爬虫1 天前
跟着 MDN 学 HTML day_8:(高级文本语义标签+适配核心功底)
前端·css·笔记·ui·html
橙子199110162 天前
UI 绘制相关
ui
Math_teacher_fan2 天前
Flutter 跨平台开发实战:鸿蒙与音乐律动艺术(六)、Lissajous 利萨茹曲线:频率耦合的轨迹艺术
flutter·ui·数学建模·华为·harmonyos·鸿蒙系统
jiejiejiejie_2 天前
Flutter for OpenHarmony 萌系 UI 实战合集:骨架屏 + 引导页一站式指南
flutter·ui·华为
Ulyanov2 天前
《现代 Python 桌面应用架构实战:PySide6 + QML 从入门到工程化》 开发环境搭建与工具链极简主义 —— 拒绝臃肿,构建工业级基座
开发语言·python·qt·ui·架构·系统仿真
Ulyanov2 天前
《现代 Python 桌面应用架构实战:PySide6 + QML 从入门到工程化》:QML 声明式语法与霓虹按钮 —— 当 Python 遇见现代美学
开发语言·python·ui·qml·系统仿真·雷达电子对抗仿真
薛定猫AI2 天前
【深度解析】Open Code Skills 工作流:用知识图谱、Spec 驱动与 UI 设计系统提升 AI Coding Agent 生产力
人工智能·ui·知识图谱