Closed factoidforrest closed 6 years ago
I got it to work. I put the router into abstract
mode where it doesn't touch or listen to the DOM.
I listen to hash change and hand the changes to Vue, after taking out the first part which is put in by single-spa.
function inheritRoute() {
let newRoute = window.location.hash.replace(/^#\/(vue-spa\/?|)/, ''); // in the future get the prefix programatically
if (newRoute === '') newRoute = '/';
console.log('newroute is ', newRoute);
Vue.$router.push(newRoute);
}
inheritRoute();
window.onhashchange = (e) => {
console.log('Updating router from hashchange with e ', e, 'and hash ', window.location.hash);
inheritRoute();
};
Parameters and lazy loading and everything seem to be working fine. Vue is really the most extensible thing.
None of the examples seem to use the Vue router and I'm struggling to get it working.
I've tried history mode and hash mode, and different "base" URLs.
Does some sort of a wrapper need to be written to make the Vue router compatible? Do we need to run Vue in an iframe(puke) to make the router work?