vue/cli - (1) 開始

// 安裝最新vue/cli
npm i -g @vue/cli

// 安裝指定版本
npm i -g @vue/[email protected]
// cd 項目位置
// apps 項目名, 不能含大寫字母
vue create apps

// 默認帶有git, 若項目中不需要
vue create apps -n
// 方向鍵上下選擇
Please pick a preset:
	Manually select features

// 空格爲選中, 回車下一步
Babel, Router, CSS.. (後續可通過"vue add cli-plugin-eslint"添加其它)

Use history mode for router?
	// n, router配置不會有"mode"和"base", 但鏈接後帶"#/"
	// y, 鏈接後不帶"#/", 但router後URL異常
		// 可刪除router配置(../router/index.js)的"mode: 'history',"

Pick a CSS pre-processor
	// Sass/SCSS (with dart-sass)

Where do you prefer placing..
	// In package.json

Save this as a preset..
	// n

 

  • 運行

更多定製 vue/cli - (2) vue.config.js

npm run serve
    http://localhost:8080

 

  • 相關版本
node -v
	v12.16.1

npm -v
	6.13.4

vue -V
	@vue/cli 4.2.3

 

  • .gitignore
node_modules

/vue.config.js
/package.json
/.*

忽略已經加入版本控制的文件, 如 vue.config.js

git update-index --assume-unchanged vue.config.js

重新加入版本控制

git update-index --no-assume-unchanged vue.config.js

 

  • 文獻

https://cli.vuejs.org/zh/guide

https://router.vuejs.org/zh/guide/essentials/history-mode.htm

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章