반응형
TypeError: vue-resource 사용 시 t.replace가 함수 오류가 아님
나는 배열된 사람들의 목록을 보여주기 위해 간단하고 아주 기본적인 Vuejs 코드를 썼다.
HTML 마크업:
<div id="container">
<ul class="list-group">
<li v-for="p in people" class="list-group-item">
{{p.first_name}} {{p.last_name}}
</li>
</ul>
</div>
그리고 이것은 Vue js 코드 입니다.
<script>
new Vue({
el: '#container',
data: {
people: []
},
mounted: function () {
this.$http.get({
url: 'example/people.json'
}).then(function (response) {
console.log(response);
this.people = response;
})
}
})
</script>
그리고people.json
파일은 다음과 같다:
[
{
"id": 1,
"first_name": "Frasier",
"last_name": "Aleksashin"
},
{
"id": 2,
"first_name": "Red",
"last_name": "Brooke"
},
{
"id": 3,
"first_name": "Iolande",
"last_name": "Lanmeid"
},
{
"id": 4,
"first_name": "Orelie",
"last_name": "Sharrock"
},
{
"id": 5,
"first_name": "Sully",
"last_name": "Huitson"
}
]
하지만 그것을 실행했을 때, 나는 크롬에서 이런 오류를 얻는다.
TypeError: t.replace is not a function
다음 오류 발생:
Uncaught (in promise) TypeError: t.replace is not a function
나는 VueJs 2를 사용하고 있다.
당신은 http를 사용하지 않는다.올바른 정보: 첫 번째 인수는 가져올 URL을 나타내는 문자열이어야 하며 두 번째 인수로 옵션 개체를 가질 수 있다.
보다 명확한 오류 메시지를 얻기 위해 개발할 때, 당신은 아마도 비조명 버전을 사용해야 할 것이다. (I got template.replace는 함수가 아니고 github의 문제로서 이것을 찾을 수 있었다.)
반응형
'Programing' 카테고리의 다른 글
_JAVA_OPTIONS, JAVA_의 차이점TOOL_OPTS 및 JAVA_OPTS (0) | 2022.04.20 |
---|---|
기존 각도 애플리케이션에 vueJS 추가 (0) | 2022.04.20 |
C의 "자유"는 왜 자유로워지는 바이트 수를 가져가지 않는가? (0) | 2022.04.19 |
JSON을 맵으로 변환 (0) | 2022.04.19 |
확인란을 Vuex 저장소에 바인딩하는 방법? (0) | 2022.04.19 |