반응형
Axios put 요청 문제
현재 블로그를 만들고 있는데 기사 편집 부분에 갇혀 있습니다.
따라서 기사 편집 페이지에서 v-model을 사용하여 vue store에서 데이터를 검색합니다.
<form action="/http://localhost:4000/articles" method="POST">
<div role="button" type="submit" @click="submitArticle">Save</div>
<div class="article-writing__inner" v-for="article in articles">
<div class="title-offset">Title</div>
<input class="input-title" type="text" v-model="article.title"/>
<tinymce id="d1"v-model="article.text"></tinymce>
</div>
</form>
v-for 루프에 대해 계산된 속성을 사용합니다.
computed: {
articles() {
return this.$store.state.articles
}
}
그리고 마지막으로 다음과 같은 공리를 사용하여 API로 데이터를 보냅니다.
methods: {
submitArticle() {
axios.put('http://localhost:4000/articles/:id', {
title: article.title,
text: article.text,
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
}
}
예상했던 대로, 저는 axios의 스토어(v-model) 데이터에 액세스할 수 없습니다.기사 생성 템플릿에서 아래와 같은 v-model을 사용하여 게시했습니다.title: this.title
.
data() {
return {
title: "",
text: ""
}
}
v-model을 로컬 구성 요소 데이터 함수 또는 axios에서 바인딩하려면 어떻게 해야 합니까?아니면 그것이 그것을 하는 또 다른 방법입니까?
시간 내주셔서 감사합니다 :)
아티클이 xios에 대한 풋 호출에서 아무것도 설정되지 않았습니다.axios 호출에서 상태 값을 파악하는 한 가지 방법은 다음과 같습니다.
submitArticle() {
let vm = this;
axios.put('http://localhost:4000/articles/:id', {
title: vm.article.title,
text: vm.article.text,
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
}
}
이것은 모두 공리 호출의 맥락에서 '이것'이 무엇인지에 대한 범위 지정에 관한 것입니다.
언급URL : https://stackoverflow.com/questions/52390596/axios-put-request-issue
반응형
'it-source' 카테고리의 다른 글
기본 웹 브라우저에서 URL 열기 (0) | 2023.06.25 |
---|---|
C#에서 MongoDB Bson 문서를 유효한 JSON으로 변환 (0) | 2023.06.25 |
How to remove unused using namespaces (0) | 2023.06.25 |
Find a document with ObjectID in mongoDB (0) | 2023.06.25 |
com.구글화력 기지파이어베이스예외:내부 오류가 발생했습니다.[ 구성_Not_Found ] (0) | 2023.06.25 |