我只需要更新commented_type
列中的评级值。在拉拉维尔上,我使用它像commented_type>评级。但是我不知道怎么做vue.js。
JSON 列如下所示:
commented_type
{"type": "review", "rating": 5}
updateReview: function () {
var reviewData = {
id:584,
commented_type>rating:'4',//It does not work like that
};
this.$http.patch('/review/584',reviewData).then((response) => {
console.log(response.data);
}, (response) => {
// error callback
console.log('error response review update')
});
},
您的 JSON 当前是否为字符串形式?如果需要获取对象,请尝试使用 JavaScript 的 JSON.parse()
。
否则,听起来您只是在询问 JS 中的属性访问器。试试这个:
commented_type['rating']