Html 引入element UI + vue3 报错Failed to resolve component: el-button

问题:Html 引入element UI + vue3 ,el-button效果不出来




  
  

  
  
  
  
  
  





{{message}} 成功按钮

运行报错:

Html 引入element UI + vue3 报错Failed to resolve component: el-button_第1张图片

index.min.js:1 Uncaught TypeError: Cannot read properties of undefined (reading '$isServer')

[Vue warn]: Failed to resolve component: el-button
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement. 
  at

问题分析:

使用vue2的话运行正常,应该是vue3与element UI不兼容。

Element UI是一款基于Vue2.x 的界面框架;Element Plus是一款基于Vue3.x 的界面框架;

Html 引入element UI + vue3 报错Failed to resolve component: el-button_第2张图片

解决

vue3的话,改用element Plus

源码:

注意:在挂载vue之前,要加载elementplus

 app.use(ElementPlus)



  
  
  
  
   
  
  

  Element Plus demo


{{ message }}

指定特定版:

 


 

效果: 

Html 引入element UI + vue3 报错Failed to resolve component: el-button_第3张图片

你可能感兴趣的:(vue.js,前端,javascript)