Vue Cli 环境安装

官方文件:https://cli.vuejs.org/#getting-started

Install:
先用npm安装

npm install -g @vue/cli# ORyarn global add @vue/cliCreate a project:

接下来就是创造阶段,分为两种方法

vue create my-project# ORvue ui

输入指令 vue create my-project (后面的my-project为资料夹名称,可以自己设定)

选择相关选项,(Router、CSS记得打勾!)

http://img2.58codes.com/2024/20150568zcGIPeiWr1.png

` Use history mode for router? (Requires proper server setup for index fallback in production) (Y/n)` 可以先选择(n)` Save this as a preset for future projects? (y/N)` 看你需不需要把这些设定储存起来,先选择(N)设定完成后就开始建档了!

跑完后进入刚刚创建的资料夹,在这边为my-project
下指令 npm run serve
运行完后会出现以下两个连结,点进去就是你的网页档案了!

    App running at:  - Local:   http://localhost:8080/  - Network: http://192.168.0.142:8080/

创建后有一些档案有出错
Parsing error: No Babel config file detected for C:\Users\USER\Desktop\vue cli\my-project\vue.config.js. Either disable config file checking with requireConfigFile: false, or configure Babel so that it can find the config files.
可以在 .eslintrc 档案里尝试增加

"parserOptions": { requireConfigFile : false }

错误就会消失。

另一个错误如下图
http://img2.58codes.com/2024/20150568mHY4fyag9M.png
解决方法如下:
◎ 找到 jsconfig.json档案,新增 "compilerOptions":{"jsx": "preserve"}
◎ 查看是否安装了Vetur插件,在vscode里的设置搜寻eslint选取左边的Vetur,取消勾选Validate vue-html in using eslint-plugin-vue

另一种安装法是

输入指令 vue ui新增专案,后面会遇到跟cmd安装十一样的选项,接下来就完成了!

关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章