Skip to content

Instantly share code, notes, and snippets.

@wszgxa
Created August 7, 2016 07:51
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save wszgxa/48eefb02650ea011ab28a116643890a9 to your computer and use it in GitHub Desktop.
Save wszgxa/48eefb02650ea011ab28a116643890a9 to your computer and use it in GitHub Desktop.
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