From 71a18c4ca0c126f3dd1b78233f25aec55710ce5b Mon Sep 17 00:00:00 2001 From: chenjiajian <798095202@qq.com> Date: Tue, 14 Jan 2020 22:07:22 +0800 Subject: [PATCH] =?UTF-8?q?feat(swan):=20=E7=99=BE=E5=BA=A6=E4=B9=9F?= =?UTF-8?q?=E5=8A=A0=E4=B8=8A=E7=BB=95=E5=BC=80=20diff=20=E7=9A=84?= =?UTF-8?q?=E5=90=8E=E9=97=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 如 #5277,百度安卓下按路径更新会导致奇怪的 bug,需要提供后门以绕过 --- packages/taro-swan/src/index.js | 6 ++++-- packages/taro-swan/src/lifecycle.js | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/taro-swan/src/index.js b/packages/taro-swan/src/index.js index a058654d175d..9122050c03b8 100644 --- a/packages/taro-swan/src/index.js +++ b/packages/taro-swan/src/index.js @@ -33,7 +33,8 @@ import { useImperativeHandle, useContext, createContext, - memo + memo, + setIsUsingDiff } from '@tarojs/taro' import { shallowEqual } from '@tarojs/utils' @@ -87,7 +88,8 @@ export const Taro = { useContext, createContext, memo, - shallowEqual + shallowEqual, + setIsUsingDiff } export default Taro diff --git a/packages/taro-swan/src/lifecycle.js b/packages/taro-swan/src/lifecycle.js index 176d43bc0cf4..72993e33d509 100644 --- a/packages/taro-swan/src/lifecycle.js +++ b/packages/taro-swan/src/lifecycle.js @@ -3,7 +3,8 @@ import { internal_safe_set as safeSet, commitAttachRef, Current, - invokeEffects + invokeEffects, + getIsUsingDiff } from '@tarojs/taro' import { componentTrigger } from './create-component' import { shakeFnFromObject, isEmptyObject, diffObjToPath, isFunction, isUndefined, isArray } from './util' @@ -173,7 +174,7 @@ function doUpdate (component, prevProps, prevState) { } data['$taroCompReady'] = true - const dataDiff = diffObjToPath(data, component.$scope.data) + const dataDiff = getIsUsingDiff() ? diffObjToPath(data, component.$scope.data) : data const __mounted = component.__mounted let snapshot if (__mounted) {