欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue路徑上如何設(shè)置指定的前綴

 更新時(shí)間:2022年07月26日 14:15:37   作者:Lou_Lan  
這篇文章主要介紹了vue路徑上如何設(shè)置指定的前綴,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

vue路徑上設(shè)置指定的前綴

有時(shí)在使用項(xiàng)目的時(shí)候,我們都需要指定一個(gè)前綴路徑(就像tomcat中的虛擬路徑),這個(gè)時(shí)候在vue中如何使用呢。

解決

這個(gè)時(shí)候我們可以使用vue-router中的base這個(gè)屬性,使用這個(gè)屬性就可以在路徑前面添加指定的前綴。

export default new Router({
? mode: 'history', //后端支持可開(kāi)
? # base: '/wtlicence',
? scrollBehavior: () => ({
? ? y: 0
? }),
? routes: constantRouterMap
});

這個(gè)時(shí)候的訪問(wèn)路徑是: http://127.0.0.1:8080/login.

當(dāng)我們使用vue-router的base屬性的時(shí)候。

export default new Router({
? mode: 'history', //后端支持可開(kāi)
? base: '/wtlicence',
? scrollBehavior: () => ({
? ? y: 0
? }),
? routes: constantRouterMap
});

這個(gè)時(shí)候的訪問(wèn)路徑是: http://127.0.0.1:8080/wtlicence/login

vue history模式、前綴

路由history模式

router/index.js

mode: 'history',
base: '/sss', // 路由前綴

路由前綴

config/index.js

開(kāi)發(fā)dev和線上build配置中,將static改成想要的前綴。

  • assetsSubDirectory: 打包后的靜態(tài)資源要存放的路徑(static)

最后,改成history模式后部署, 刷新會(huì)有問(wèn)題。需要更改服務(wù)器配置(config)

server{
	listen      8888;
	server_name  localhost;
	root html
	location / { 
	    try_files $uri $uri/ @router; 
	    index index.html index.htm; 
	}
	location @router { 
		rewrite ^.*$ /index.html last; 
	}
}

新增的主要是:

location / {
try_files $uri KaTeX parse error: Expected 'EOF', got '}' at position 51: …l index.htm; }? location @rou… /index.html last;
}

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論