Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'includes')

        <select v-model="selectedCategory">
          <option :key="index" v-for="(data,index) in selectItems" :value="data">{{ data.title }}</option>
        </select>
        <p>{{ selectedCategory.data }}</p>

        else if (newExpanded[0].includes("Duplicated"))
        {
          this.assetCodeInfo=[{ASSET_CODE: this.Category[0]}];
          this.clickedHistoryDate=[];
          //아래 넘어가지 않도록 return으로 끝내기
          return;
        }

          :class="{ deleted: item.IS_DELETED}"

i tried this. but
TypeError: Cannot read properties of null (reading 'data')
is yelling like this.

solutions

add a condtion. Like under.

        <p v-if="selectedCategory">{{ selectedCategory.type }}</p>

        else if (newExpanded[0]&& newExpanded[0].includes("Duplicated"))
        {
          this.assetCodeInfo=[{ASSET_CODE: this.Category[0]}];
          this.clickedHistoryDate=[];
          //아래 넘어가지 않도록 return으로 끝내기
          return;
        }

      return Array.isArray(this.assetCodeInfo) ? this.assetCodeInfo.filter(entry=>entry.UPDATE_DATE===this.clickedHistoryDate):[];

          :class="{ deleted: item && item.IS_DELETED }"

 


but why? it like a java's try, catch?s



'🖥️FE🖥️ > 📗Vue📗' 카테고리의 다른 글

Shallow Copy Deep Copy  (1) 2023.11.26
Vue Emit 간단한 실습 코드  (0) 2023.11.23
Watch 와 Computed 차이.  (1) 2023.11.22
vue-router  (0) 2023.10.30
Vue  (0) 2023.10.24

+ Recent posts