今天跳转的时候遇到一个问题

在子组件中

this.$router.push({
path:'/easylearn'
})

报错,no $router

后面差错,是因为写了箭头函数的缘故,this指向了当前域

这里应该直接用函数写

goFirst正常,goSecond报错

methods:{
    goFirst(){
      console.log(this)
      this.$router.push({
        path:'/easylearn'
      })
    },
    goSecond:(()=>{
       this.$router.push({}) 
    })
 },

相关文章:

  • 2021-09-21
  • 2021-07-03
  • 2021-10-24
  • 2021-11-21
  • 2022-12-23
  • 2021-05-23
  • 2021-08-20
  • 2022-12-23
猜你喜欢
  • 2021-04-20
  • 2021-09-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-14
相关资源
相似解决方案