在项目的根目录添加vue.config.js文件,添加以下内容
module.exports = {
publicPath: process.env.NODE_ENV === 'production'
? './' : '/'
}
lintOnSave: false,
devServer: {
overlay: {
warning: false,
errors: false
}
}
执行
cnpm install --global vue-cli
//报错信息
error code ELIFECYCLE
21 error errno 1
22 error [email protected] build: `vue-cli-service build`
22 error Exit status 1
23 error Failed at the [email protected] build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
npm install -g cnpm --registry=https://registry.npm.taobao.org
npm install -g nrm
nrm ls
nrm use taobao
main.js里面导入
import './assets/iconfont/iconfont.js
App.vue加上style
.icon {
width: 1em; height: 1em;
vertical-align: -0.15em;
fill: currentColor;
overflow: hidden;
}
引用
<svg class="icon myIconStyle" aria-hidden="true">
<use :xlink:href="'#' + dbIcon[item.type]"></use>
</svg>