From 8612b3b87abff1d11fea138f711c0d76bdb556d3 Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 1 Dec 2020 23:58:15 +0800 Subject: [PATCH] =?UTF-8?q?fix=E6=8F=90=E4=BE=9B=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=93=8D=E5=BA=94=E5=BC=8F=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=9A=84=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/fix/fix.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/dist/fix/fix.js b/dist/fix/fix.js index 412000142..19c076e5b 100644 --- a/dist/fix/fix.js +++ b/dist/fix/fix.js @@ -359,7 +359,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons uniq[name] = true; } } - //添加访问器属性 + //添加访问器属性 for (name in accessors) { if (uniq[name]) { continue; @@ -1106,10 +1106,11 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons } var computedWatcherOptions = { lazy: true }; + var REACTIVE = true; function initState(vm, state) { if (state) { - vm.$$state = observe(state).model; + vm.$$state = REACTIVE ? observe(state).model : state; } } @@ -1170,7 +1171,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons if (watcher.dirty) { watcher.evaluate(); } - if (Dep.target) { + if (REACTIVE && Dep.target) { watcher.depend(); } return watcher.value; @@ -1382,7 +1383,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons this.init(); initState(this, _.extend(getInjectValues(this), state)); initComputed(this, computed); - initWatch(this, watch$$1); + REACTIVE && initWatch(this, watch$$1); initMethods(this, actions); this.created && this.created(); this._destroyHandler = destroyHandler; @@ -1418,6 +1419,13 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons return Model; }(); + function config(options) { + options || (options = {}); + if ("reactive" in options) { + REACTIVE = options.reactive; + } + } + function toJSON(model) { var result = void 0; if (_.isArray(model)) { @@ -1448,6 +1456,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons exports.$$skipArray = $$skipArray; exports.mixin = mixin; exports.Model = Model; + exports.config = config; exports.observerState = observerState; exports.Observer = Observer; exports.observe = observe; @@ -1462,4 +1471,4 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons exports.toJSON = toJSON; exports.__esModule = true; -}); +}); \ No newline at end of file