我對(duì) vue.js 比較陌生,尤其是 nuxt。我有一個(gè)小功能可以從后端獲取數(shù)據(jù)并更新表格。我不確定如何調(diào)試這個(gè)任務(wù),因?yàn)槲以趻燧d的鉤子中調(diào)用它,當(dāng)我加載頁(yè)面時(shí),我可以在 vuex 選項(xiàng)卡中看到數(shù)據(jù)。payload:Objectcount:2next:nullprevious:nullresults:Array[2]0:Object1:Objectcreated_at:"2020-09-14T12:00:00Z"event_name:"wrw"id:2market_name:"wrwr"market_type:"wrwr"odds:242 runner_name:"wrwr"side:"wrwrw"stake:424由于某種原因,我無(wú)法填充表格。 我可以看到頁(yè)面加載后每三秒調(diào)用一次函數(shù)pollData() 。我不確定為什么我看不到表中的數(shù)據(jù)。如何使用 vuex 數(shù)據(jù)更新表? <template> <div id="app"> <h1>Orders</h1> <table> <thead class="thead-dark"> <tr> <th>Time Stamp</th> <th>Event Name</th> <th>Market Name</th> <th>Market Type</th> <th>Runner Name</th> <th>Side</th> <th>Odds</th> <th>Stake</th> </tr> </thead> <tbody> <tr v-for="o in polling" :key="o.id"> <td>{{o.created_at}}</td> <td>{{o.event_name}}</td> <td>{{o.market_name}}</td> <td>{{o.market_type}}</td> <td>{{o.runner_name}}</td> <td>{{o.side}}</td> <td>{{o.odds}}</td> <td>{{o.stake}}</td> </tr> </tbody> </table> </div> </template> <script> import axios from "axios"; import { mapMutations } from 'vuex' export default { data () { return { polling: null } }, methods: { pollData () { this.polling = setInterval(() => { this.$store.dispatch('getOrders') }, 3000) } }, beforeDestroy () { clearInterval(this.polling) }, mounted () { this.pollData() } } </script>
Vue JS-無(wú)法使用來(lái)自 Vuex 的數(shù)據(jù)更新 html 表
30秒到達(dá)戰(zhàn)場(chǎng)
2023-04-27 16:18:54