VueJs-$ route在页面加载时不可用

时间:2018-09-06 10:14:15

标签: vue.js

我似乎对Vue有问题,我正在运行它来处理正在编译的Vue UI。我正在尝试解决VueJs - Passing query in query string as prop的问题,但是我注意到了以下内容,但不确定为什么。

URL = http://localhost:8080/?q=This%20is%20my%20query

mounted () {
    console.log(this.$route.query.q)
    console.log(this.$route.query)
}

鉴于上面的URL和console.log,下面的输出正在发生。我不知道为什么结果不一样

首次访问网址

undefined
Object {  }

重新编译并Vue UI重载后

This is my query
Object { q: "This is my query" }

为什么在第一次加载时看不到this.$route

0 个答案:

没有答案
相关问题