第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

從組件獲取數(shù)據(jù)到另一個頁面視圖

從組件獲取數(shù)據(jù)到另一個頁面視圖

幕布斯6054654 2023-12-19 16:16:40
有一個組件“TableFields.vue”和兩個視圖文件“Home.vue”。和“Statistics.vue”。在組件中,我在 對象下有 changes: [] 變量。data()  data () {    return {      startStopA: true,      startStopB: true,      initialValueA: 3,      initialValueB: 3,      randomNumbersArray: [],      randomSignA: '+',      randomSignB: '+',      signsArray: ['+', '-'],      intervalA: null,      intervalB: null,      changes: []    }  },該changes數(shù)組從calculationsA()函數(shù)動態(tài)獲取對象。    calculationsA () {      this.randomSignA = this.signsArray[        Math.floor(Math.random() * this.signsArray.length)      ]      this.randomSignA === '+'        ? (this.initialValueA += this.randomNumbersArray[0])        : (this.initialValueA -= this.randomNumbersArray[0])      const d = new Date()      // console.log(d.toLocaleTimeString())      // console.log(this.randomNumbersArray[0])      // this.changes.push(this.randomNumbersArray[0])      // this.changes.push(d.toLocaleTimeString())      // console.log(this.changes)      const newChange = {}      newChange.field = 'A'      newChange.value = this.randomNumbersArray[0]      newChange.time = d.toLocaleTimeString()      this.changes.push(newChange)    },如何將 changes: [] 從 TableField.vue 組件傳遞到 Statistics.vue 頁面,以便使用 編寫動態(tài)表格a> 中看到。 組件的工作代碼,可以從根 url changes 數(shù)組對象數(shù)據(jù)。我不確定,我是否需要創(chuàng)建新組件,或者沒有它也可以完成?;旧?,這是出于測試目的而實現(xiàn)的 TableField.vueHome.vue    <div class="statistics">      <table>        <tr>          <th>Field</th>          <th>Value</th>          <th>Time</th>        </tr>        <tr v-for="item in changes" :key="item.value">          <td>{{ item.field }}</td>          <td>{{ item.value }}</td>          <td>{{ item.time }}</td>        </tr>      </table>    </div>  </div>我需要該代碼才能在 Statistics.vue 頁面上運行。為了更加方便,這里是 鏈接 gitlab 存儲庫。
查看完整描述

2 回答

?
LEATH

TA貢獻1936條經(jīng)驗 獲得超7個贊

據(jù)我所知,更好的解決方案應(yīng)該是使用 Vuex (https://vuex.vuejs.org/),它允許您將數(shù)據(jù)存儲在稱為存儲的共享點中。

您也可以使用此處記錄的事件:https://v2.vuejs.org/v2/guide/components-custom-events.html#Binding-Native-Events到組件


查看完整回答
反對 回復 2023-12-19
?
鴻蒙傳說

TA貢獻1865條經(jīng)驗 獲得超7個贊

您可以在 中導入 TableField.vue 并將 作為 props 傳遞。Statistics.vuechanges: []



查看完整回答
反對 回復 2023-12-19
?
FFIVE

TA貢獻1797條經(jīng)驗 獲得超6個贊

用戶“異步”來自discord vue chat 已經(jīng)為我解決了這個問題。
解決方案有點復雜,需要更改幾個文件。
如果您想了解更多信息,請參閱 gitlab repo,因為由于其復雜性,我無法在此處記錄它。

查看完整回答
反對 回復 2023-12-19
  • 2 回答
  • 0 關(guān)注
  • 190 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號