Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.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
Typescript 财产';历史';不存在于类型';VueRouter';在vue ts中_Typescript_Vue.js_Vue Router_Eslint_Typescript Typings - Fatal编程技术网

Typescript 财产';历史';不存在于类型';VueRouter';在vue ts中

Typescript 财产';历史';不存在于类型';VueRouter';在vue ts中,typescript,vue.js,vue-router,eslint,typescript-typings,Typescript,Vue.js,Vue Router,Eslint,Typescript Typings,我在一个应用程序中使用typescript vue,我在一个组件中遇到了这个错误,在该组件中,我试图访问传递到路由中的参数,如下所示 properties = getModule(PropertiesModule, this.$store); mounted() { id = this.$router.history.current.params.id; this.properties.getProperty(id); } get months() { r

我在一个应用程序中使用typescript vue,我在一个组件中遇到了这个错误,在该组件中,我试图访问传递到路由中的参数,如下所示

  properties = getModule(PropertiesModule, this.$store);
  mounted() {
    id = this.$router.history.current.params.id;
    this.properties.getProperty(id);
  }
  get months() {
    return this.$store.state.app.months;
  }
  get property() {
    return this.$store.state.properties.property;
  }
}
这段代码运行得很好,因为据我所知,这不是一种不当行为。但是typescript仍然抛出错误。我试着在下一行使用es lint disable,但它不起作用。我也试着在我的main.ts中给路由器加上any的类型,但效果不太好。 在vue.js中有没有比这更好的访问路由器参数的方法


您可以使用Vue.js中的
$route.params
获取参数

如果您想要获取
id
param,这可能会解决

this.$route.params.id