由于之前项目使用vue-cli2.x创建项目,现做vue-cli3.x创建项目记录
yarn管理工具安装
官方地址:https://yarn.bootcss.com/docs/install/#windows-stable 下载安装
1.脚手架安装
npm install -g @vue/cli
yarn global add @vue/cli
2.创建项目
vue create hello-world
3.跨域配置
官方文档地址: https://cli.vuejs.org/zh/config/#vue-config-js
根目录新建vue.config.js文件,配置基本跨域
devServer: {
proxy: ‘http://localhost:4000’
}
或
proxy: {
‘/api’: {
target: ‘’,
ws: true,
changeOrigin: true,
pathRewrite : {‘^/api’:’’}
}
}