vue当中的this.$router.go(n)这个方法不支持safari浏览器及大部分iphone

vue当中的this.$router.go(n)这个方法不支持safari浏览器这个问题一直未能解决:

this.$router.go('/center');

当运行后页面不会刷新,这在safari以及iphone上会出现的问题。

Github上给出的说法:

Hello, came across a bug with VueRouter 2.0.1 and iOS Safari on iPhone only.
If I use the history mode of the Router which is supposed to be supported by the browser it fails and triggers a page refresh instead of changing the state.
You can try it with the official example fiddle here: http://jsfiddle.net/yyx990803/xgrjzsup/
Just change the mode to history and test iOS Safari on an iPhone.
The workaround is simple, I use userAgent detection instead of feature detection to check for iPhone and Safari and change the mode back to hash.
I have no idea of what is causing the page refresh, it's not the history API as using a regular window.History.pushState() works in the browser.
It's works fine in simulator. But in iPhone 6S iOS 10.1 will refresh the page.

这个在chrome浏览器上进行没有问题。。。

猜你喜欢

转载自blog.csdn.net/yanpenggong/article/details/81414827