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

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

具有 Vue(2) 綁定的 HTML 表格行

具有 Vue(2) 綁定的 HTML 表格行

呼喚遠方 2023-08-18 13:53:01
我有一個購物車/訂單列表,我將其綁定到一個工作正常的數(shù)組。我最近為添加到數(shù)組中的每個項目添加了一個行號,還有一個按鈕行。問題是我將它們綁定到當前行,如下所示<div id="table">    <table class="table table-sm table-bordered table-striped">      <thead class="thead-dark">        <tr>          <th scope="col">#</th>          <th scope="col">Product</th>          <th scope="col">Type</th>          <th scope="col">Attribute</th>          <th scope="col">Height</th>          <th scope="col">Width</th>          <th scope="col">Price</th>          <th width="1%" scope="col">Remove</th>        </tr>      </thead>        <tbody>          <tr v-for="(item, index) in table_products">            <td>{{ index +1 }}</td>            <td>{{ item.product }}</td>            <td>{{ item.type }}</td>            <td>{{ item.attribute }}</td>            <td>{{ item.height }}</td>            <td>{{ item.width }}</td>            <td>{{ item.price }}</td>            <td><button class="btn btn-danger" @click="deleteRow(index)">X</button></td>          </tr>         </tbody>      </table>    </div>  </div>我從來沒有遇到過問題,因為綁定項值為空,因此從未創(chuàng)建該行。但現(xiàn)在索引和按鈕創(chuàng)建表的第一行。有沒有辦法可以在頁面加載時清除數(shù)組,或者我是否以錯誤的方式進行操作?
查看完整描述

1 回答

?
梵蒂岡之花

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

我初始化 table_products [{}]而不是[]

從初始化開始,它在數(shù)組中有一個空對象,因此它有一個元素。初始化一個空數(shù)組解決了這個問題,因為它沒有元素。


查看完整回答
反對 回復(fù) 2023-08-18
  • 1 回答
  • 0 關(guān)注
  • 116 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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