2017-06-09 22 views
0

我需要僅更新commented_type列中的評分值。在Laravel上,我使用了類似於評論類型>評分。但我不知道如何做vue.js。Vue.js:以分貝更新子json數據格式

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') 
    }); 
}, 

回答

0

是您目前的JSON字符串形式的?如果您需要獲取對象,請嘗試使用JavaScript的JSON.parse()

否則,這聽起來像你只是問JS中的property accessors。試試這個:

commented_type['rating']