噩耗噩耗!vue-cli2还没完全搞懂,就更新到 vue-cli3 啦~~~~~
1. 卸载旧版本
如果你之前如果你已经全局安装了旧版本的 vue-cli (1.x 或 2.x),你需要先通过 npm uninstall vue-cli -g
或 yarn global remove vue-cli
卸载它。
2. Node 版本要求
Vue CLI 需要 Node.js 8.9 或更高版本 (推荐 8.11.0+)。你可以使用 nvm 或 nvm-windows 在同一台电脑中管理多个 Node 版本。在命令指示符中验证一下新版的nodejs是否安装成功
3. 下载新的vue包
cnpm install -g @vue/cli
# OR
yarn global add @vue/cli
验证一下vue版本是否更新成功4. 新建vue3.0的项目
vue create hello-world
先选好指定文件夹,然后create
,接着一路“傻瓜式安装”就ok啦~
5. 运行程序
yarn serve
使用vue3好处
项目文件清晰明了
6. 获得程序如何开启
yarn
yarn lint
升级npm到最新版本
npm install -g npm@latest
实例操作步骤
- 在要新建项目的文件夹中,shift+右键选择“在此处打开Powershell窗口”
-
vue create demo
选择二第二项自定义,然后回车
按下图选择,确定选择哪项按空格键,最后确认回车
编码规范
module.exports = {
root: true,
env: {
node: true
},
'extends': [
'plugin:vue/essential',
'@vue/standard'
],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'semi': ['error', 'always'], // 必须使用分号
'comma-dangle': ['error', 'only-multiline'], // 拖尾逗号
'require-jsdoc': ['error', {
'require': {
'FunctionDeclaration': true,
'MethodDefinition': false,
'ClassDeclaration': false,
'ArrowFunctionExpression': false,
'FunctionExpression': false
}
}],
},
parserOptions: {
parser: 'babel-eslint'
}
};
webpack配置
添加element-ui到dependencies中
yarn add element-ui
添加element-ui到devDependencies中
yarn add element-ui -D