vue环境的搭建
第一步
先确保安装了nodejs和npm
命令行执行:
C:\Users\86189> npm -v
10.8.2
C:\Users\86189> node -v
v20.17.0
第二步: 安装vue
由于npm在国外,这里使用国内淘宝镜像源:
设置淘宝镜像源
npm config set registry https://registry.npmmirror.com
查看镜像源:
npm config get registry
输出应该是:
https://registry.npmmirror.com/
安装vue脚手架: 直接在命令行执行,记得使用管理员身份打开终端
npm install -g @vue/cli
第三步:创建vue项目
创建一个空文件夹, 在vscode打开,并打开终端
执行命令:
vue create blogdemo # blogdemo是项目名
可能会遇到这个错误:
这时打开 PowerShell, 执行该命令即可:
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
配置一系列信息: 方向键上下选择,空格键选中, 回车完成当前选项
Please pick a preset: Manually select features
? Check the features needed for your project: Babel, Router, Vuex, CSS Pre-processors
? Choose a version of Vue.js that you want to start the project with 2.x
? Use history mode for router? (Requires proper server setup for index fallback in production) No
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): Less
? Where do you prefer placing config for Babel, ESLint, etc.? In package.json
? Save this as a preset for future projects? No
然后切换到项目文件夹下执行 npm run serve 运行项目即可