我正在使用Vueitfy的v-chip組件,在點擊十字圖標時隱藏/顯示芯片。文檔指出要添加布爾值v-ifdata() { return { chips:{}, tests: [], tabs: ["Parameters", "Start Time", "Trafic Source"], disabledButtons: true, };},這里的chips對象是我需要動態化的。為此,我將動態生成的名稱推送到芯片對象中:mounted() { this.tests = this.$store.state.run.runScheduled; //adding dynamic chip into chips array which will be used to hide/show individual chips for (let test in this.tests) { let chipName="Chip"+test; this.chips[chipName]=true; }}對 HTML 標記做同樣的事情<div class="chips-wrapper"> <span v-for="(test, index) in tests" :key="index"> <v-chip v-if="`chips.Chip${test.id}`" class="tags" close label @click:close="RemoveTest(test.id)" > {{ test.name }} </v-chip> </span></div>removetest()是我需要將檢查設置為 false 以便它對 DOM 隱藏的地方,但由于某種原因代碼無法正常工作methods: { RemoveTest(testID) { let chipName=`Chip${testID}`; console.log(chipName); this.chips.chipName=false },}如果我嘗試打印芯片對象,它會顯示預期生成的鍵/值對{ "Chip0": true, "Chip1": true, "Chip2": true, "Chip3": true}方法內的代碼removeTest()應該將值更改為 false,但事實并非如此,有什么幫助嗎?
動態生成的對象密鑰不更新
交互式愛情
2023-09-28 17:16:22