亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

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

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

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

解決

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

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

這個時候的訪問路徑是: http://127.0.0.1:8080/login.

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

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

這個時候的訪問路徑是: http://127.0.0.1:8080/wtlicence/login

vue history模式、前綴

路由history模式

router/index.js

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

路由前綴

config/index.js

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

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

最后,改成history模式后部署, 刷新會有問題。需要更改服務(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;
}

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

相關(guān)文章

最新評論