Browse Source

fix提供配置是否响应式数据的选项

master
guy 4 years ago
parent
commit
8612b3b87a
  1. 15
      dist/fix/fix.js

15
dist/fix/fix.js vendored

@ -1106,10 +1106,11 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
} }
var computedWatcherOptions = { lazy: true }; var computedWatcherOptions = { lazy: true };
var REACTIVE = true;
function initState(vm, state) { function initState(vm, state) {
if (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) { if (watcher.dirty) {
watcher.evaluate(); watcher.evaluate();
} }
if (Dep.target) { if (REACTIVE && Dep.target) {
watcher.depend(); watcher.depend();
} }
return watcher.value; return watcher.value;
@ -1382,7 +1383,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
this.init(); this.init();
initState(this, _.extend(getInjectValues(this), state)); initState(this, _.extend(getInjectValues(this), state));
initComputed(this, computed); initComputed(this, computed);
initWatch(this, watch$$1); REACTIVE && initWatch(this, watch$$1);
initMethods(this, actions); initMethods(this, actions);
this.created && this.created(); this.created && this.created();
this._destroyHandler = destroyHandler; this._destroyHandler = destroyHandler;
@ -1418,6 +1419,13 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
return Model; return Model;
}(); }();
function config(options) {
options || (options = {});
if ("reactive" in options) {
REACTIVE = options.reactive;
}
}
function toJSON(model) { function toJSON(model) {
var result = void 0; var result = void 0;
if (_.isArray(model)) { if (_.isArray(model)) {
@ -1448,6 +1456,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
exports.$$skipArray = $$skipArray; exports.$$skipArray = $$skipArray;
exports.mixin = mixin; exports.mixin = mixin;
exports.Model = Model; exports.Model = Model;
exports.config = config;
exports.observerState = observerState; exports.observerState = observerState;
exports.Observer = Observer; exports.Observer = Observer;
exports.observe = observe; exports.observe = observe;

Loading…
Cancel
Save