legendnan
V2EX  ›  Vue.js

$router.push 不跳转? 遇到个问题求助!

  •  
  •   legendnan · Jul 25, 2020 · 3425 views
    This topic created in 2132 days ago, the information mentioned may be changed or developed.

    我做了个登录页面。

    async onSubmit(values) { const { data:res } = await this.$http.get('index/hello') // if(res.meta.status =='200') return console.log("登录成功") this.$router.push("/home")

    }
    

    我这样写的。为啥在电脑上能跳转到 home 在手机上点了啥反应没有呢?

    Supplement 1  ·  Jul 25, 2020
    async onSubmit(values) {
    const
    { data:res }=await this.$http.get('index/hello')
    this.$router.push("/home")

    }
    Supplement 2  ·  Jul 25, 2020
    没法上传图片真烦人!下面代码是手机打的,我给判断屏蔽了!
    3 replies    2020-07-26 08:35:02 +08:00
    lisianthus
        1
    lisianthus  
       Jul 25, 2020
    是不是因为 status 是 200 而直接 return 了
    legendnan
        2
    legendnan  
    OP
       Jul 25, 2020 via Android
    @lisianthus 我给他屏蔽 1 了啊?
    liyg04120414
        3
    liyg04120414  
       Jul 26, 2020
    用 vconsole 调试下,看看有没有报错,如果没有,换 this.$router.push({name: 'xxx'})试试
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3068 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 14:03 · PVG 22:03 · LAX 07:03 · JFK 10:03
    ♥ Do have faith in what you're doing.