Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
ios document title refreash in vue-router
``` js
/**
* fix ios title刷新不了的bug
* @iframeLoad
* @author hiluluke
*/
const iframeLoad = function (src) {
let iframe = document.createElement('iframe')
iframe.style.display = 'none'
iframe.src = src
document.body.appendChild(iframe)
iframe.addEventListener('load', function () {
setTimeout(function () {
iframe.remove()
}, 0)
})
}
// document title change
router.afterEach((transition) => {
document.title = transition.to.title || 'CNode.js'
if (navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) {
let src = '/static/fixrouter.html?' + Math.random()
iframeLoad(src)
}
})
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment