背景:创建了一个简单的vue工程想用测试一下el-input组件的功能,没有显示图标。代码如下所示
<template> <el-input v-model="value" placeholder="请输入内容" :disabled="false" :show-password="true" :clearable="true" prefix-icon="el-icon-edit" type="text"></el-input> </template> <script setup> import { ref } from 'vue' const value = ref('') </script>
其中在main.js中定义了图标的加载
import { createApp } from 'vue' import App from './App.vue' import ElementPlus from 'element-plus' import 'element-plus/dist/index.css' // import * as ElIconModules from '@element-plus/icons' import * as ElementPlusIconsVue from '@element-plus/icons-vue' const app = createApp(App) // 统一注册el-icon图标 // for(let iconName in ElIconModules){ // app.component(iconName,ElIconModules[iconName]) // } for (const [key, component] of Object.entries(ElementPlusIconsVue)) { app.component(key, component) } app.use(ElementPlus) app.mount('#app')
标签:el,search,vue,app,import,图标,icon From: https://www.cnblogs.com/lixianhui/p/18098958