V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
legendnan
V2EX  ›  Vue.js

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

  •  
  •   legendnan · 2020-07-25 16:53:46 +08:00 · 2662 次点击
    这是一个创建于 1361 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我做了个登录页面。

    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 在手机上点了啥反应没有呢?

    第 1 条附言  ·  2020-07-25 18:13:23 +08:00
    async onSubmit(values) {
    const
    { data:res }=await this.$http.get('index/hello')
    this.$router.push("/home")

    }
    第 2 条附言  ·  2020-07-25 18:14:07 +08:00
    没法上传图片真烦人!下面代码是手机打的,我给判断屏蔽了!
    3 条回复    2020-07-26 08:35:02 +08:00
    lisianthus
        1
    lisianthus  
       2020-07-25 17:16:55 +08:00
    是不是因为 status 是 200 而直接 return 了
    legendnan
        2
    legendnan  
    OP
       2020-07-25 18:11:14 +08:00 via Android
    @lisianthus 我给他屏蔽 1 了啊?
    liyg04120414
        3
    liyg04120414  
       2020-07-26 08:35:02 +08:00
    用 vconsole 调试下,看看有没有报错,如果没有,换 this.$router.push({name: 'xxx'})试试
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3352 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 13:05 · PVG 21:05 · LAX 06:05 · JFK 09:05
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.