vue-cli初始化專案及介紹

初始化腳手架
1.1 說明
- Vue 腳手架是 Vue 官方提供的標準化開發工具(開發平臺),
- 最新的版本是 4.x,
- 檔案: https://cli.vuejs.org/zh/,
- 1.2 具體步驟
第一步(僅第一次執行):全域安裝@vue/cli,
npm install -g @vue/cli
第二步:切換到你要創建專案的目錄,然后使用命令創建專案
vue create xxxx
第三步:啟動專案
npm run serve
備注: - 如出現下載緩慢請配置 npm 淘寶鏡像:npm config set registry
https://registry.npm.taobao.org
專案其他配置



組件路由搭建注意點

路由傳參的三種方式
methods: {
//搜索按鈕的回呼函式,需要向search路由跳轉
gosearch() {
//路由傳參3中形式
//第一種:字串形式
this.$router.push(
"/search" + this.keyword + "?k=" + this.keyword.toUpperCase()
);
//第二種:模板字串
this.$router.push(
`/search/${this.keyword}?k=${this.keyword.toUpperCase()}`
);
//第三種:物件
this.$router.push({
name: "search",
params: { keyword: this.keyword },
query: { k: this.keyword.toUpperCase() },
});
},
},

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/387853.html
標籤:其他
上一篇:騰訊作業8年,肝到10級就剩這份學習筆記了,已助朋友拿到10個Offer
下一篇:Redfish介面測驗
