vue项⽬使⽤svg-icon
第⼀步  npm i -D svg-sprite-loader
第⼆步  f.js下添加
{
test: /\.svg$/,
loader: 'svg-sprite-loader',
include: [resolve('src/icons')],
options: {
symbolId: 'icon-[name]'
}
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
exclude: [resolve('src/icons')],
options: {
limit: 10000,
name: utils.assetsPath('img/[name].[hash:7].[ext]')
}
},
第三步  src⽬录下新建⽂件夹icons,其中svg⽂件夹下放svg类型的图⽚,index.js代码如下import Vue from 'vue'
import SvgIcon from '@/components/SvgIcon'// svg component
Vueponent('svg-icon', SvgIcon)
const req = t('./svg', false, /\.svg$/)
const requireAll = requireContext => requireContext.keys().map(requireContext)
requireAll(req)第
第四步在components下新建⽂件夹SvgIcon,index.vue代码如下
<!-- 组件说明 -->
<template>
<svg  class="svg-icon">
<use :xlink:href="iconName" />
</svg>
</template>
svg怎么转为pdf
<script>
//import x from ''
export default {
name: "SvgIcon",
props: {
iconClass: {
type: String,
required: true
},
},
computed: {
iconName() {
return `#icon-${this.iconClass}`;
},
}
};
</script>
<style scoped>
.svg-icon {
width: 1em;
height: 1em;
vertical-align: -0.15em;
fill: currentColor;
overflow: hidden;
}
</style>
第五步在main.js中引⼊import './icons'
第六步如何使⽤<svg-icon icon-class="user" />