關(guān)于創(chuàng)建項(xiàng)目
windows下,習(xí)慣了用git bash 來(lái)輸入node命令巴元,結(jié)果在使用vue-cli3.0創(chuàng)建項(xiàng)目時(shí), 出現(xiàn)無(wú)法選擇配置項(xiàng)的情況下驮宴,改用終端命令即可逮刨。
git base
window 命令提示符
通過(guò)上下鍵選擇默認(rèn)(default)還是手動(dòng)(manually)。選擇手動(dòng)堵泽,通過(guò)空格來(lái)控制是否選中:
vue.config.js
修改配置之后修己,需要運(yùn)行 npm run build
,重新構(gòu)建下項(xiàng)目迎罗,否則所做的修改可能不會(huì)生效睬愤。
devServer.proxy
設(shè)置代理的時(shí)候,path
纹安,如https://example.com:8042/over/there?name
尤辱,寫(xiě)前面的over
會(huì)生效砂豌,換成there
卻無(wú)效。(path
is used for context matching.
)
proxy: {
'/interface': {
target: 'https://www.abc.com', //目標(biāo)域名或IP
ws: false, //是否代理websocket
secure: true, //https 開(kāi)啟
changeOrigin: true, // 跨域開(kāi)啟
pathRewirte: {
'^/interface': '/interface' //https://www.abc.com/interface/xxx
}
}
},
foo://example.com:8042/over/there?name=ferret#nose
\_/ \______________/\_________/ \_________/ \__/
| | | | |
scheme authority path query fragment
public
2.0
的index.html
頁(yè)面移入到public
中啥刻,一些不想打包的文件可以直接放入到public
中奸鸯。如demo.html
可以通過(guò)http://localhost:8080/demo.html
直接訪問(wèn)(2.0的需要在前面添加static
)。
demo.html
多頁(yè)面創(chuàng)建
vue-cli 3.0
創(chuàng)建多頁(yè)面應(yīng)用的話(huà)可帽,只需要設(shè)置下pages
即可娄涩。
pages: {
index: {
// page 的入口
entry: 'src/main.js',
// 模板來(lái)源
template: 'public/index.html',
// 在 dist/index.html 的輸出
filename: 'index.html',
// 當(dāng)使用 title 選項(xiàng)時(shí),
// template 中的 title 標(biāo)簽需要是 <title><%= htmlWebpackPlugin.options.title %></title>
title: 'Index Page',
// 在這個(gè)頁(yè)面中包含的塊映跟,默認(rèn)情況下會(huì)包含
// 提取出來(lái)的通用 chunk 和 vendor chunk蓄拣。
chunks: ['chunk-vendors', 'chunk-common', 'index']
},
// 當(dāng)使用只有入口的字符串格式時(shí),
// 模板會(huì)被推導(dǎo)為 `public/subpage.html`
// 并且如果找不到的話(huà)努隙,就回退到 `public/index.html`球恤。
// 輸出文件名會(huì)被推導(dǎo)為 `subpage.html`。
subpage: 'src/subpage/main.js',
//入口荸镊,模板咽斧,輸出
demo: {
entry: 'src/demo/demo.js',
template: 'src/demo/demo.html',
filename: 'demo.html',
}
},
局部目錄結(jié)構(gòu)