Vue route jump:
setTimeout(function () { console.log(this); this.$router.push("/login"); },800)
The syntax is OK, but an error is reported:
MyFollow.vue?c93c:119 Uncaught TypeError: Cannot read property 'push' of undefined
At this time, it means that the direction of this is different. You should print this and have a look
it is found that this in the setTimeout function points not to the Vue object but to the window. It can be solved by changing the arrow function
The function settimeout will change this to point to the global window, if it does not change this to point to the global window, use the arrow function here setTimeout(()=>{ this.$router.push("/login"); },100)
Similar Posts:
- [Solved] Vue router common problems (push error, push duplicate route refresh)
- The applet reports an error thirdscripterror DateValue is not defined;
- Vue: How to use Vue-router in Axios
- [Solved] Vue Error: NavigationDuplicated: Avoided redundant navigation to current location: “xxx”.
- [Solved] Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to
- [Solved] VUE Project Error: Avoided redundant navigation to current location: “/XXX“
- Vue new page Jump [Three Method to Use]
- [Solved] Vue router in the element UI navigation bar repeatedly clicks on the menu above version 3.0 and reports errors
- How to Fix Git push warning: push.default is unset;
- How to Solve Vue Error: NavigationDuplicated