vue3無法顯示element-plus問題及解決
vue3無法顯示element-plus
原本想使用el-tree做目錄,結果找了很久的原因都無法顯示,并且沒有任何報錯,但是在調(diào)試的過程中發(fā)現(xiàn)el-tree使用的數(shù)據(jù)是對象形式的
并且還報了el-tree組件無法解析
runtime-core.esm-bundler.js:38 [Vue warn]: Failed to resolve component: el-tree If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
剛開始以為需要解析數(shù)據(jù),但是其他人都可以正常使用,所以嘗試放其他組件,結果其他組件也都無法使用,那么很有可能是掛載出現(xiàn)問題
因為將所有需要掛載使用的變量放在了一個use里導致的,還是得多熟悉才行
正確使用方法
vue3使用Element-plus的圖標
首先安裝Element-Plus-icon
# 選擇一個你喜歡的包管理器 # NPM $ npm install @element-plus/icons-vue # Yarn $ yarn add @element-plus/icons-vue # pnpm $ pnpm install @element-plus/icons-vue
如何使用
Element-Plus-icon官方文檔鏈接
https://element-plus.org/zh-CN/component/icon.html#icon-collection
在main.ts中引入Element-Plus-icon
import * as ElementPlusIconsVue from '@element-plus/icons-vue' Object.keys(ElementPlusIconsVue).forEach((key) => { app.component(key, ElementPlusIconsVue[key]) })
- 第一種直接點擊圖標復制<el-icon>
<el-icon><ArrowRight /></el-icon>
- 第二種通過icon="el-icon-plus"
<el-button type="success" icon="el-icon-plus" > 1111 </el-button>
- 第三種通過SVG
<template> <div style="font-size: 20px"> <!-- 由于SVG圖標默認不攜帶任何屬性 --> <!-- 你需要直接提供它們 --> <Edit style="width: 1em; height: 1em; margin-right: 8px" /> <Share style="width: 1em; height: 1em; margin-right: 8px" /> <Delete style="width: 1em; height: 1em; margin-right: 8px" /> <Search style="width: 1em; height: 1em; margin-right: 8px" /> </div> </template>
總結
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
Ant Design moment對象和字符串之間的相互轉(zhuǎn)化教程
這篇文章主要介紹了Ant Design moment對象和字符串之間的相互轉(zhuǎn)化教程,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-10-10Vue+Elementui el-tree樹只能選擇子節(jié)點并且支持檢索功能
這篇文章給大家介紹了Vue+Element UI el-tree樹只能選擇子節(jié)點并且支持檢索的文章,通過實例代碼給大家介紹的非常詳細,感興趣的朋友跟隨小編一起看看吧2024-12-12vue-cli3.0如何使用CDN區(qū)分開發(fā)、生產(chǎn)、預發(fā)布環(huán)境
這篇文章主要介紹了vue-cli3.0如何使用CDN區(qū)分開發(fā)、生產(chǎn)、預發(fā)布環(huán)境,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-11-11vue內(nèi)置動態(tài)組件component使用示例小結
component是vue內(nèi)置組件,主要作用為動態(tài)渲染組件,這篇文章主要介紹了vue內(nèi)置動態(tài)組件component使用示例小結,需要的朋友可以參考下2024-03-03