# vue-project-template **Repository Path**: darcrandex/vue-project-template ## Basic Information - **Project Name**: vue-project-template - **Description**: 基于 vue-cli 3.x 搭建的项目模板 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2018-08-29 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### 配置项 1. 没有使用 eslint,不喜欢 2. 默认就配置了路径别名 `@ -> ./src` 3. `publicPath`设置为`./`。主要是因为项目不会放到磁盘根目录 ### less 全局变量 安装`style-resources-loader`,然后在`vue.config.js`中添加配置。 ``` const path = require("path") const stylePath = "./src/assets/styles/variables.less" module.exports = { publicPath: "./", chainWebpack: config => { const types = ["vue-modules", "vue", "normal-modules", "normal"] types.forEach(type => addStyleResource(config.module.rule("less").oneOf(type))) } } function addStyleResource(rule) { rule.use("style-resource") .loader("style-resources-loader") .options({ patterns: [path.resolve(__dirname, stylePath)] }) } ``` 让`.vue`,`.less`都能识别全局变量。 ### vuex公共的mutation 在`/src/utils/index.js`中,新增了`setState`方法。该方法作为公共的`mutation`,这样在执行`actions`时就不需要单独触发对应的`mutation`,使用公共的修改`state`的`setState`方法就可以了。