【发布时间】:2021-11-18 00:23:37
【问题描述】:
我正在尝试使用 beforeEnter() 为 path 的外部链接 with query string 定义路由,如下所示:
Vue.use(VueRouter)
const routes = [
{
path: '/',
beforeEnter() {location.href = '/path='+this.$router.query.path},
name: 'Home',
component: Home3
},
但是我遇到了一个错误“无法读取未定义的属性(读取 $route)”。
我应该如何使用查询将正确的定义写入外部链接?
【问题讨论】:
标签: vue.js vue-router