Programing

TypeError: vue-resource 사용 시 t.replace가 함수 오류가 아님

c10106 2022. 4. 19. 21:30
반응형

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의 문제로서 이것을 찾을 수 있었다.)

참조URL: https://stackoverflow.com/questions/44481880/typeerror-t-replace-is-not-a-function-error-when-using-vue-resource

반응형