Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript VueJS路由器:$未定义路由_Javascript_Vue.js_Vuejs2_Vue Component_Vue Router - Fatal编程技术网

Javascript VueJS路由器:$未定义路由

Javascript VueJS路由器:$未定义路由,javascript,vue.js,vuejs2,vue-component,vue-router,Javascript,Vue.js,Vuejs2,Vue Component,Vue Router,这是我的组件: const Vue=require(“Vue/dist/Vue.js”); 常量qs=要求(“查询字符串”); module.exports=Vue.component(“页面”,函数(解析){ 控制台日志($route); 设id=this.$route.params.id; 获取(“/getPage.json”{ 方法:“张贴”, 正文:qs.stringify({ 身份证件 }) }).then(r=>r.json()) .然后(j=>{ 控制台日志(j); 决心({ 模

这是我的组件:

const Vue=require(“Vue/dist/Vue.js”);
常量qs=要求(“查询字符串”);
module.exports=Vue.component(“页面”,函数(解析){
控制台日志($route);
设id=this.$route.params.id;
获取(“/getPage.json”{
方法:“张贴”,
正文:qs.stringify({
身份证件
})
}).then(r=>r.json())
.然后(j=>{
控制台日志(j);
决心({
模板:`+JSON.stringify(j)+“”
});
})
});

new Vue(...)
您必须先使用vue路由器

import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
...
new Vue(...)
...

并且继续执行路由声明

您忘记在
Vue
实例中添加
router

在main.js或app.js或index.js(入口点)中


您不应该使用箭头功能

data: function() {
    return {
      usertype: this.$route.params.type
    };
  },
这对我很有用。

我正在使用
Vue.use(VueRouter)
data: function() {
    return {
      usertype: this.$route.params.type
    };
  },