Vue-router .push operation cannot be redirected?

I created a login component
router

export default new Router({
  mode : "history",
  routes: [
    {
      path: "/login",
      name: "login",
      component: login
    },
    {
      path: "/test",
      name: "test",
      component : app
     }
  ]
})```

url http://localhost:8080/login

< template >

 <input type="text" class="form-control" placeholder="user" v-model="name">
 <input type="password" class="form-control" placeholder="password" v-model="password">
 <input type="submit" class="btn btn-primary " @click="login" >

< / div >
< / template >

< script >

export default {
   data(){
     return{
       password:"",
       name:""
     }
     },
   methods:{
      login(){
          const self = this;
          this.$axios({
            method:"post",
            url:"/api/login",
            data : {
              name : this.name,
              password: this.password
            }
          }).then(response =>{
            console.log("response" + response.data)
            if (response ==="0")
              console.log("wrong user")
            else if(response === "1")
              console.log("wrong pwd")
            else if (response === "2"){
              self.$router.replace("/test");
              console.log("OK")
            }

          })
      }
   }
}
response === 2
 this.$router.push("/test/");
url
Mar.07,2021

this.$router.push ('/ test');
'/ test/' may match the test subordinate route?


this.$router.replace ('/')


vue suggests naming the component, which is convenient for error prompts and routing. After naming, you can use this.$router.push ({name:'xxxx'}). To pass parameters, first add parmas: {id:'123'} to the route definition parameter format such as path:'/abcd/:id', in push.


you should post your router code and take a look at your routing configuration.


is mostly a problem with routing configuration. The solution can be found in ide/routing.html" rel=" nofollow noreferrer "> official route

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2b9de-2bab5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2b9de-2bab5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?