Skip to content

Commit 42c5d64

Browse files
committed
修复this.arr.push(1) 不触发更新问题
1 parent ae83e99 commit 42c5d64

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/platforms/mp/runtime/diff-data.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ function getDeepData (keyList, viewData) {
1919
}
2020
}
2121

22-
function compareAndSetDeepData (key, newData, vm, data) {
22+
function compareAndSetDeepData (key, newData, vm, data,forceUpdate) {
2323
// 比较引用类型数据
2424
try {
2525
const keyList = key.split('.')
2626
// page.__viewData__老版小程序不存在,使用mpvue里绑的data比对
2727
const oldData = getDeepData(keyList, vm.$root.$mp.page.data)
28-
if (oldData === null || JSON.stringify(oldData) !== JSON.stringify(newData)) {
28+
if (oldData === null || JSON.stringify(oldData) !== JSON.stringify(newData) || forceUpdate) {
2929
data[key] = newData
3030
}
3131
} catch (e) {
@@ -45,7 +45,7 @@ function minifyDeepData (rootKey, originKey, vmData, data, _mpValueSet, vm) {
4545
try {
4646
if (vmData instanceof Array) {
4747
// 数组
48-
compareAndSetDeepData(rootKey + '.' + originKey, vmData, vm, data)
48+
compareAndSetDeepData(rootKey + '.' + originKey, vmData, vm, data,true)
4949
} else {
5050
// Object
5151
let __keyPathOnThis = {} // 存储这层对象的keyPath

0 commit comments

Comments
 (0)