無法讀取未定義的屬性錯誤:Vue綁定物件屬性的類別綁定類型錯誤
P粉617237727
P粉617237727 2023-08-26 23:55:21
0
1
524

我正在嘗試根據物件屬性綁定一個類,但是當我點擊列表物件觸發@click 時,控制台告訴我無法讀取isSelected 的物件屬性... 我正在嘗試在動態渲染的清單項目上使用函數來接收項目的id,並將此屬性設為false 或true 時觸發一個類別來啟動

希望有人能告訴我下面的程式碼中我漏掉了什麼,謝謝 :)

  • {{day.val}}

我的 vue 資料

data:function(){ return{ year: 2021, month: 1, day: 1, days:[18,19,20,21], January:[ {name: 'January', isSelected: false, id: 1, val:1}, {name: 'January', isSelected: false, id: 2, val:2}, {name: 'January', isSelected: false, id: 3, val:3}, {name: 'January', isSelected: false, id: 4, val:4}, {name: 'January', isSelected: false, id: 5, val:5}, {name: 'January', isSelected: false, id: 6, val:6}, {name: 'January', isSelected: false, id: 7, val:7}, {name: 'January', isSelected: false, id: 8, val:8}, {name: 'January', isSelected: false, id: 9, val:9}, {name: 'January', isSelected: false, id: 10, val:10}, {name: 'January', isSelected: false, id: 11, val:11}, {name: 'January', isSelected: false, id: 12, val:12}, {name: 'January', isSelected: false, id: 13, val:13}, {name: 'January', isSelected: false, id: 14, val:14}, {name: 'January', isSelected: false, id: 15, val:15}, {name: 'January', isSelected: false, id: 16, val:16}, {name: 'January', isSelected: false, id: 17, val:17}, {name: 'January', isSelected: false, id: 18, val:18}, {name: 'January', isSelected: false, id: 19, val:19}, {name: 'January', isSelected: false, id: 20, val:20}, {name: 'January', isSelected: false, id: 21, val:21}, {name: 'January', isSelected: false, id: 22, val:22}, {name: 'January', isSelected: false, id: 23, val:23}, {name: 'January', isSelected: false, id: 24, val:24}, {name: 'January', isSelected: false, id: 25, val:25}, {name: 'January', isSelected: false, id: 26, val:26}, {name: 'January', isSelected: false, id: 27, val:27}, {name: 'January', isSelected: false, id: 28, val:28}, {name: 'January', isSelected: false, id: 29, val:29}, {name: '一月', isSelected: false, id: 30, val:30}, {name: '一月', isSelected: false, id: 31, val:31}, ], 二月:[], 行進:[], 四月:[], 可能:[], 六月:[], 七月:[], 八月:[], 九月:[], 十月:[], 十一月:[], 十二月:[], } },

評價 isSelected == true 時的 css 類別

.addedToTrip{ 背景顏色:#2E9CFE; 頂部邊框:.5px 純黑色; 邊框底部:.5px 純黑色; }

P粉617237727
P粉617237727

全部回覆 (1)
P粉709307865

在指定類別名稱時,你需要使用單引號

ul class="daysList"> 
  • // 改变 added {{day.val}}
    • 最新下載
      更多>
      網站特效
      網站源碼
      網站素材
      前端模板
      關於我們 免責聲明 Sitemap
      PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!