VueJS:如何获取路线网址?

时间:2018-02-28 21:48:37

标签: laravel vuejs2

我在Vue的laravel工作,我无法获得路线网址 例如,有路由localhost:8000 / chat / 3,我需要在路由中获得3 我尝试在app.js中写入

data: {
    userId: this.$route.params
}

然后在

created() {
    console.log(this.userId);
}

所以我可以向该路线发送ajax请求。但它返回TypeError: this.$route is undefined。我还尝试了除params之外的其他内容,但总是显示此错误

0 个答案:

没有答案
相关问题