Problem description

To invoke the wechat JSSDK method, you need to perform signature first, and the URL of the current page is required. However, the actual URL is not refreshed during page hopping in ios. The URL obtained when you sign the JSSDK page to be invoked is actually the URL of the first page to be entered, which causes a signature failure.

The solution

Reload the page when it jumps to refresh the URL

router.beforeEach((to, from, next) => { console.log('beforeEach from', from, to) console.log('to path', to.path, location) const toPath = process.env.VUE_APP_PUBLIC_PATH + to.path if (! isAndroid() && toPath ! == location.pathname) { location.assign(process.env.VUE_APP_PUBLIC_PATH + to.fullPath) } next() }) function isAndroid() { const u = navigator.userAgent const isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1 console.log('isAndroid', isAndroid) return isAndroid }Copy the code

In ios, each skipping page is equivalent to refreshing the current page. Therefore, the data stored in VUEX is cleared and the keep-Alive page cache cannot be used