欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

element-plus 在vue3 中不生效的原因解決方法(element-plus引入)

 更新時(shí)間:2022年08月16日 10:37:47   作者:顏值與實(shí)力并存源  
這篇文章主要介紹了element-plus 在vue3 中不生效的原因解決方法(element-plus引入),本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

vue3.0 不兼容 element-ui ,于是推出了element-plus

1.安裝element-plus (3種方式 )

npm install element-plus --save (推薦)
yarn add element-plus
pnpm install element-plus

2. 在main.js種引用

import 'element-plus/theme-chalk/index.css' 					   //默認(rèn)css樣式 英文
import Element from 'element-plus'              				   //引入插件
import zhCn from 'element-plus/es/locale/lang/zh-cn'               //引入中文包

 //全局 使用element-plus  
																   //中文使用
 createApp(App).use(Element,{locale:zhCn}).mount('#app')
																   //默認(rèn)英文使用
  createApp(App).use(Element).mount('#app')

引入最重要看官方引入方法
官方引入方法:
https://element-plus.org/es-ES/guide/quickstart.html#configuracion-global
正常引入不生效的原因如下

原因一

main.js中加載順序不對(duì)

import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus';
import 'element-plus/lib/theme-chalk/index.css';

const app = createApp(App)
app.use(ElementPlus)
app.use(router).mount('#app')

原因二

  <el-tree
          ref="elTreeRef"
          :data="menus"
          show-checkbox
          node-key="id"
          :props="{ children: 'children', label: 'name' }"
          @check="handleCheckChange"
        >

import { ElTree } from 'element-plus'

 const elTreeRef = ref<InstanceType<typeof ElTree>>()
    const editCallback = (item: any) => {
      const leafKeys = menuMapLeafKeys(item.menuList)
      nextTick(() => {
        console.log(elTreeRef.value)
        elTreeRef.value?.setCheckedKeys(leafKeys, false)
      })
    }

有的時(shí)候全局注冊(cè),但是不生效的原因,只能在template中可以使用,在js邏輯中使用組件名稱方法還是需要單獨(dú)引入的

到此這篇關(guān)于element-plus 在vue3 中不生效的原因解決方法(element-plus引入)的文章就介紹到這了,更多相關(guān)element-plus vue3 不生效內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論