准备

1.需要先安装node.js,并保证node版本在10.0以上。

2.使用官方脚手架VueCLI ,地址https://cli.vuejs.org/zh/guide/installation.html

1
2
安装命令
npm install -g @vue/cli

创建项目

1.使用vue create xxxx进行创建项目

img_name

2.回车以后选择Manually select features

img_name

注解:前两个表示默认模板,一个表示vue2一个表示vue3,如果没有发现vue3选项表示你的VueCLI是旧版本。因为我们要使用TS进行开发,在前两项默认模板中是没有TS支持的,所有要选择第三项表示手动选择特效。

3.设置配置信息,选择TypeScript

img_name

注解:使用上下键进行移动,空格键进行选择,选择TypeScript 以及Css

4.选择版本3.x

img_name

5.后面操作步骤一直按回车键即可

配置饿了么UI组件

饿了么Ui组件vue3.0项目地址:https://element-plus.gitee.io/#/zh-CN

1
2
安装命令
npm install element-plus --save

https://standardjs.com/rules-zhcn.html

npm install element-plus –save

1
2
3
4
安装vuex全局状态管理
npm install vuex --save
安装进度条
npm install nprogress --save

http://www.axios-js.com/zh-cn/docs/#Semver

npm install vue-router@4

https://getbootstrap.com/

1
npm install bootstrap@next

在Vue中使用path-to-regexp的报错问题

在页面点击按钮时出现以下错误:
[Vue warn]: Error in v-on handler: "TypeError: Cannot read property 'compile' of undefined"

当时以为是compile正则函数出现问题,但是改了半天发现并不是这个原因,最后发现是path-to-regexp引入方式的问题,我刚开始是这样:

1
import pathToRegexp from 'path-to-regexp'

改成这种引入方式就可以了

1
import * as pathToRegexp from 'path-to-regexp'