【发布时间】:2019-04-06 21:35:52
【问题描述】:
我目前正在我们学校做我的顶点项目。目前我正在为我的 csr 使用 nuxt、vue、vuex 和 vuetify 并为 ssr 使用 express。 在我的代码中,我想从 v-for 获取数据,然后传递给我的组件以查询另一个数据..
//my code in parent component
<template>
<v-list-group v-else v-for='(items, index) in halfpayments' :key="index">
<v-list-tile slot='activator'>
<v-list-tile-title><span class="subheading">{{items.ordnameto}}</span></v-list-tile-title>
</v-list-tile>
<v-list-tile>
<halfpay text='black--text' :ids='items.id'/>
</v-list-group>
</template>
<script>
import halfpay from '@/components/custom/fullHalfpay'
export default {
components: {
halfpay
}
}
//code in child component
<template>
<v-flex>
<v-list-tile v-for='(item) in data' :key="item.id">
<v-list-tile-content>
<v-list-tile-sub-title><span class="caption">Full payment date: </span><span :class="text">{{$dateFilter(item.paid_time)}}</span></v-list-tile-sub-title>
</v-list-tile-content>
</v-list-tile>
</v-flex>
</template>
<script>
export default{
props: {
ids: {
type: String,
required: true
},
text:{
type: String,
required: true
}
},
computed: {
data(){
return this.$store.getters.halffullpay(this.ids)
}
}
}
</script>
它的输出,v-for 会渲染子组件的所有数据。有没有办法以特定方式获取数据。唯一的方法是合并 2 个单独的数据,但从长远来看它会使逻辑复杂化,因为子节点是一个条件渲染,它需要满足应用子组件的条件。
【问题讨论】: