【发布时间】:2020-08-09 10:11:03
【问题描述】:
我尝试了How to get Vue Router Params in Vuex?,但似乎不起作用。
吸气剂:
getAssetById: state => id => {
return state.assets.find(asset => asset.id === id)
}
组件:
<div class="card padding-35 box-shadow ">
//this on is OK
{{ assetId }}
{{ asset }}
</div>
computed: {
assetId() {
return this.$route.params.id
},
asset() {
//this doesn't work
return this.$store.getters.getAssetById(assetId)
}
asset() {
//this work
return this.$store.getters.getAssetById(1)
}
}
【问题讨论】:
-
你得到什么错误?
标签: vue.js vuex vue-router