Vue写法
vue 写法
new Vue({
el: '#app',
router,
store,
template: '<Layout/>',
components: { Layout },
render: function (createElement) {
if ('-ms-scroll-limit' in document.documentElement.style && '-ms-ime-align' in document.documentElement.style) {
window.addEventListener('hashchange', () => {
var currentPath = window.location.hash.slice(1)
if (this.$route.path !== currentPath) {
this.$router.push(currentPath)
}
}, false)
}
return createElement(Layout);
}
})
nuxt写法
nuxt 版本 server.js 不能修改。 你只能自己在plugins 添加一个 ie.js 文件 , 然后在nuxt.config.js --plugins 引入 { src: '~plugins/ie', ssr: false },
import Vue from "vue";
const IE11RouterFix = {
methods: {
hashChangeHandler: function() {
this.$router.push(
window.location.hash.substring(1, window.location.hash.length)
);
},
isIE11: function() {
return !!window.MSInputMethodContext && !!document.documentMode;
},
},
mounted: function() {
if (this.isIE11()) {
window.addEventListener("hashchange", this.hashChangeHandler);
}
},
destroyed: function() {
if (this.isIE11()) {
window.removeEventListener("hashchange", this.hashChangeHandler);
}
},
};
export default new Vue({ mixins: [IE11RouterFix] });