全局安装vue
cnpm install -g @vue-cli
vue -V
//检测是否安装成功
不要安装cnpm install --global vue-cli
,不然用不了
不小心安装了就卸载 npm uninstall -g vue-cli
创建项目:vue create item_name
默认模式或手动模式 【手动】
选择安装特性 【如图】
选typescript的话,不是js文件,而是ts文件
路由配置,Y为history,N为hash 【n】
Eslint 【选第一个不做任何Eslint检查】
不然默认的检查太多,新人动不动就报错了。多个空格,就会报错:Trailing spaces not allowed no-trailing-spaces
样式的检查是在save时还是在commit时 【save】
配置文件是独立还是全部集成到package.json 【独立】
是否保存配置方案为以后适用 【n】
eslint规则配置:
根目录新建一个.eslintrc.js文件
module.exports = {
root: true,
env: {
node: true
},
'extends': [
'plugin:vue/essential',
'eslint:recommended'
],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
"no-mixed-spaces-and-tabs": "off",
"no-unused-vars":"off" //已定义未使用
},
parserOptions: {
parser: 'babel-eslint'
}
}