私は何が...このvueが必要なのか理解できません!できる場合は をお手伝いください! これは、「作成」、「読み取り」、「更新」私は4ブールフィールドを持つ例えばcurrentFullDataでVue JSが1つの配列でデータを変更すると、
var groupadding = new Vue({
el: '#groupAdd',
data:{
currentFullData: [],
localData: []
},
methods: {
getDepartment() {
var sendData = id; // this is example
this.$http.post('some api ', sendData, {emulateJSON: true})
.then(resp => {
this.currentFullData = resp.data;
}
},
getLocalDepartment() {
this.localData = this.currentFullData;
}
}
})
私のコードで、
「を削除」は、この4つのフィールドには、あまりにものlocalDataを取得しますが、とき私はそれらのいくつかのlocalDataの変更、彼らはあまりにもcurrentFullDataの変更!!!!!!!!!!!!!!!
SOOOOOO誰もがWTFはこれです、私を説明できますか?!?!?!
NOP、同じ結果を参照することができ、より理解するために、この
this.localData = this.currentFullData.slice()
よう
this.localData
にthis.currentFullData
の参照を渡す... :( – JorjiniああNVM、私はそれを見ていません配列であってオブジェクトではありません。クローンと配列のためのanchal20答えを参照してください。 – reinarg
私の答えは申し訳ありません。 this.currentFullData = cloneArray(this.currentFullData、data); function cloneArray($ name、$ array) { リターン$名= JSON.parse(JSON.stringify($配列));} このWOOOOOOOOOOOOOOOOOORKS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ありがとうございました!!!! – Jorjini