正常情况下按钮可以加图标:
但一直不显示,所以把加图标过程记录一下:
安装
使用npm:
npm install @element-plus/icons-vue
使用
在需要的页面中导入需要的图标:
import { Search } from '@element-plus/icons-vue' //导入Search图标
这时假设直接使用:
<el-button type="primary" :icon="Search">Search</el-button>
eslint会报 'Search' is defined but never used
解决方法是:
观察到icon使用的是v-bind,所以在data里面添加:
data() {
return {
Search:Search
}
},
这样就正常了