Browse Source

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

es6
guy 4 years ago
parent
commit
8612b3b87a
  1. 19
      dist/fix/fix.js

19
dist/fix/fix.js vendored

@ -359,7 +359,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
uniq[name] = true; uniq[name] = true;
} }
} }
//添加访问器属性 //添加访问器属性
for (name in accessors) { for (name in accessors) {
if (uniq[name]) { if (uniq[name]) {
continue; continue;
@ -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;
@ -1462,4 +1471,4 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
exports.toJSON = toJSON; exports.toJSON = toJSON;
exports.__esModule = true; exports.__esModule = true;
}); });
Loading…
Cancel
Save