别的不多说,开始动爪把,
首先安装vue-cli mac:
sudo npm install -g @vue/cligithub:
https://github.com/XinYueXiao/vue-routes
1、Vue-cli基础使用
1.1 创建测试项目 vue create vue-routes

1.2 创建成功,启动项目 yarn serve
在 http://localhost:8080/ 就可以看到欢迎:clap:页面了

1.3 搞点自定义配置,新建vue.config.js
const title = '双11剁手啦'
const port = '1111'
module.exports = {
publicPath: '/wxy',
//自定义端口号
devServer: {
port
},
//自定义变量
configureWebpack: {
name: title
}
}配置完成后重新启动
yarn serve 效果图
如何配置svg图标
1)准备一个svg,例如:
src/icons/svg/hg.svg2)安装loader
yarn add svg-sprite-loader3)对config进行链式操作即可修改loader
const path = require('path')
//处理地址
function resolve(dir) {
return path.join(__dirname, dir)
}
module.exports = {
...,
chainWebpack(config) {
//安装loader,对config进行链式操作即可修改loader、plugins
//1.svg rule中要排除icons目录
config.module.rule('svg')
//转换为绝对地址
.exclude.add(resolve('src/icons'))
//查看配置后svg规则 vue inspect --rule svg
//2.添加一个规则icons
config.module.rule('icons')
.test(/.svg$/)
.include.add(resolve('src/icons')).end()
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.options({
symbolId: 'icon-[name]'
})
}
}4)svg rule中要排除icons目录后配置

5) 添加一个规则icons配置

6) 新建
src/components/SvgIcon.vue 模板
<template>










