I need to detect the back function in the browser and need to redirect to a different page using vue js. My attempt is as below.
mounted: function () {
window.onpopstate = function(event) {
this.$router.push({
path: "/register"
});
};
}
But it will not identify $router and saying it's not a function. How can I solve this problem?