鍍金池/ 問答/HTML/ 請(qǐng)問怎么把v-for遍歷里的對(duì)象保存到data里,以便methods里的方法調(diào)用

請(qǐng)問怎么把v-for遍歷里的對(duì)象保存到data里,以便methods里的方法調(diào)用?

clipboard.png
我用v-for遍歷了一個(gè)數(shù)組
之前用的動(dòng)態(tài)路由傳參的方式傳遞detail里的對(duì)象,成功!
clipboard.png
但是寫到后面感覺太繁瑣了,想用編程式路由,但是要怎么獲取到detail里的值呢?
我這樣寫的

clipboard.png
但是值為空,
有人說可以用索引值方式獲取,但是我寫不來,第一次寫項(xiàng)目,求大神指點(diǎn)。。

回答
編輯回答
薔薇花

template:

<div v-for="detail in details" @click="toRouter(detail)"></div>

methods:

toRouter (detail) {
    this.$router.push({path: '/comment', query: {table: detail}})
}
2018年7月13日 18:24
編輯回答
真難過
this.$router.push({path:'/comment',query{table:this.detail}});

跳轉(zhuǎn)頁面獲取
this.$route.query.table
2017年6月14日 10:15