第一種,每次打開選項卡時,默認選中第一個
<!-- 選項卡 -->
<el-tabs v-model="activeName" type="card" @tab-click="handleClick" >
<el-tab-pane label="產品信息" name="first"> </el-tab-pane>
<el-tab-pane label="產品圖片" name="second"> </el-tab-pane>
</el-tabs>
data中定義activeName,存在每次切換的狀態
在編輯對話框彈出之前,this.activeName="first"
第二種,保留上一次打開選項卡的狀態,重新請求里面的內容
//判斷打開的選項卡,請求對應的數據,
console.log("對話框展開的內容"+this.activeName)
if (this.activeName === "first") {
//打開的是第一個選項卡
} else if (this.activeName === "second") {
//打開的是第二個選項卡
//根據產品的ID,請求對應的圖片地址數組
await this.getImageByProductId()
} else if (this.activeName ==="third") {
//打開的是第三個選項卡
//獲取所有的文件信息
await this.GetFileByProductId()
}
//展開對話框
this.editProductDialogVisible = true
