Cộng đồng Hỏi & Đáp của Inflearn
Elements in iteration expect to have 'v-bind:key' directives. 에러 발샐 질문
Viết
·
596
1
<template>
<div>
<div v-for="user in users">{{ user.title }}</div>
</div>
</template>
<script>
import axios from 'axios';
export default {
data() {
return {
users: []
}
},
created() {
var vm = this;
axios.get('https://api.hnpwa.com/v0/news/1.json')
// es5 문법
.then(function(response){
console.log(response);
vm.users = response.data;
})
.catch(function(error){
console.log(error);
})
// es6 문법
// .then(response => vm.users = response.data)
// .catch()
},
}
코드를 이렇게 작성했는데.. <div v-for="user in users">{{ user.title }}</div> 부근에서 에러가 발생합니다.
에러 내용은 Elements in iteration expect to have 'v-bind:key' directives. 라는 에러가 발생하는데
어떻게 해결해야 하나요 ?
긴급vuejsjavascript
Câu trả lời 2
2
0
captain
Người chia sẻ kiến thức
안녕하세요 Bino님, v-for 디렉티브를 사용할 때는 v-bind:key를 꼭 지정해 주어야 합니다. 강의 뒤쪽에 아마 안내가 될 거에요 :) 종수님 대신 답변해 주셔서 감사해요!





