Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.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
Vue.js 通过ID Vuejs从对象数组传递数据_Vue.js_Axios_Vuetify.js - Fatal编程技术网

Vue.js 通过ID Vuejs从对象数组传递数据

Vue.js 通过ID Vuejs从对象数组传递数据,vue.js,axios,vuetify.js,Vue.js,Axios,Vuetify.js,我有2.vue页面(列表、详细信息) 现在在列表中,我列出了像这样的对象数组,我从API中获取它们 [{…},{…},{…}] 我用v-for在列表中显示它 我在每个列表中都有详细信息按钮 单击“详细信息”时,我将使用对象ID路由到“详细信息”页面 我可以在控制台中打印ID,也可以在.vue 使用:$this.route.params.ID 但是我无法在ID=$this.route.params.ID 我已经试了三天了 {{cmpd.name}({{cmpd.city}) 细节 {{cmpd.

我有2.vue页面(列表、详细信息) 现在在列表中,我列出了像这样的对象数组,我从API中获取它们

[{…},{…},{…}]

我用v-for在列表中显示它

我在每个列表中都有详细信息按钮

单击“详细信息”时,我将使用对象ID路由到“详细信息”页面

我可以在控制台中打印ID,也可以在
.vue
使用:
$this.route.params.ID

但是我无法在ID=
$this.route.params.ID

我已经试了三天了


{{cmpd.name}({{cmpd.city})
细节
{{cmpd.name}

我看到您正在使用
CompoundID:cmpd.ID
传递ID。但是你想要所有的对象和信息,对吗?那么为什么不传递整个对象呢<代码>参数:{component:cmpd}
。那么你就拥有了整个物体


如果您正在使用Vuex,您也可以将其放在存储中,以便从任何地方进行访问。

请显示您的路由器文件{path:“/CompoundDetails/:CompoundID”,name:“CompoundDetails”,component:CompoundDetails},我认为您的路径错误
/list/:CompoundID
因为您来自list PageVuetify还提供:支持v-card,因此您的参数名为
CompoundID
,而不是
ID
,因此您应该使用
此。$route.params.CompoundID