npm install wen-icon --save
配置 vue-svg-icon-loader
1. webpack 配置
npm install vue-svg-icon-loader -save-dev
module.exports = {
module: {
rules: [
{
test: /\.svg$/,
resourceQuery: /wen-icon/,
use: "vue-svg-icon-loader"
}
]
}
}
2. vue-cli 配置
npm install vue-svg-icon-loader --save-dev
module.exports = {
chainWebpack: (config) => {
const svgRule = config.module.rule("svg");
svgRule.uses.clear();
svgRule.use("vue-svg-icon-loader")
.resourceQuery(/wen-icon/)
.loader("vue-svg-icon-loader");
}
}
// 1. 引入
import { WenIcon } from "wen-icon";
// 2. 局部注册组件
components: { WenIcon }
// 3. template 中使用
<template>
<wen-icon name="annotation">
</template>
<template>
<wen-icon name="annotation" width="48px" height="48px" />
</template>
<template>
<wen-icon name="annotation" fill="red" />
</template>
<template>
<wen-icon name="annotation" stroke="red" />
</template>