【发布时间】:2019-08-11 23:04:34
【问题描述】:
我尝试从 url 获取参数
假设网址包含:
localhost:8000/blog?q=hello
我要抢hello触发函数调用
我在 laravel webpack 的 app.js 中声明的内容:
import VueRouter from 'vue-router';
Vue.use(VueRouter);
const router = new VueRouter({
mode: 'history',
routes: []
})
const app = new Vue({
router
});
export default app;
在博客页面中,我尝试从url中提取参数
new Vue ({
el: "#blog-content",
},
mounted: function() {
q = this.$route.query.q
console.log(q)
}
)
我npm run dev编译运行博客页面显示错误:
TypeError: Cannot read property 'query' of undefined
怎么了?我确信 Vue Router 已正确安装在应用程序中。
【问题讨论】:
标签: laravel-5 vue-router