1.安装
vue create project
npm install
npm run serve
2.使用axios作为请求库
npm install axios
3.使用sass预编译处理css
npm install -D sass-loader node-sass
4.使用style-resources-loader处理全局自动导入(变量、mixin、var)
npm install -D style-resources-loader
// vue.config.js
const path = require('path')
module.exports = {
chainWebpack: config => {
const types = ['vue-modules', 'vue', 'normal-modules', 'normal']
types.forEach(type => addStyleResource(config.module.rule('scss').oneOf(type)))
},
}
function addStyleResource (rule) {
rule.use('style-resource')
.loader('style-resources-loader')
.options({
patterns: [
path.resolve(__dirname, './src/common/css/import.scss'),
],
})
}
5.使用.editorconfig美化代码风格
vs code需要下载插件才能使用
EditorConfig for VS Code。