当url中出现"#"号时,"#"及其后面的字符串都会被浏览器忽略,不会被发送到抓信服务器,所以抓信的token服务器在做身份识别跳转的时候会丢失后面的参数。
怎么办呢,要去掉vue中访问地址中的#符号可以在路由器中设置路由模式为history:export default new Router({
mode:'history',
routes: [
{
path: '/',
name: 'Home',
component: Home
},
{
path: '/news',
name: 'News',
component: News
},
{
path: '/goods',
name: 'Goods',
component: Goods
},
{
path: '/detail/:id',
name: 'Detail',
component: Detail
}
]
})
如果是问号后的对参数有井号,进行转义就行了,利用js的escape()函数即可转义:
这样"#"会被转义成"%23",而后台的cs代码会自动将其恢复成转义之前的"#"。