IOS 与 vuejs 2.0 结合的注意事项
访问量: 2659
在 vuejs 1.0 的时候, ios可以正常的拦截到 vuejs的页面跳转,并进行各种对应的操作.
但是很奇怪是,我们发现在vue 2.0中, ios是可以察觉到vuejs的跳转意图, 但是无法阻止页面的跳转的.
所以, 目前的解决办法, 是在 vuejs中解决. 如果发起request的是ios, 那么 就在vuejs中加上钩子方法来进行判断:
let router = new VueRouter({
// 各种路由的定义
})
router.beforeEach((to, from, next) => {
console.info(to)
console.info(from)
console.info('跳转了')
let link
if (to.query.client === 'ios') {
link = true
} else if (from.query.client === 'ios'){ // 请求过来的 request 中一定要带上 client=ios
console.info('full_path ===' + to.fullPath)
window.location.href = 'http://link_to' + to.fullPath
link= false
} else {
link = true
}
next(link) // 通过这个来判断.
})