Browse Source

支持BI.useContext

es6
guy 3 years ago
parent
commit
a9a19943e8
  1. 7
      src/core/4.widget.js

7
src/core/4.widget.js

@ -784,6 +784,8 @@
}; };
BI.watch = function (vm, watch, handler) { BI.watch = function (vm, watch, handler) {
// 必须要保证组件当前环境存在
if (BI.Widget.current) {
if (vm instanceof BI.Model) { if (vm instanceof BI.Model) {
var watchers = []; var watchers = [];
if (BI.isKey(watch)) { if (BI.isKey(watch)) {
@ -806,11 +808,10 @@
} }
} }
// vm中一定有_widget // vm中一定有_widget
vm._widget._watchers || (vm._widget._watchers = []); BI.Widget.current._watchers || (BI.Widget.current._watchers = []);
vm._widget._watchers = vm._widget._watchers.concat(watchers); BI.Widget.current._watchers = BI.Widget.current._watchers.concat(watchers);
return; return;
} }
if (BI.Widget.current) {
handler = watch; handler = watch;
watch = vm; watch = vm;
BI.Widget.current.$watchDelayCallbacks || (BI.Widget.current.$watchDelayCallbacks = []); BI.Widget.current.$watchDelayCallbacks || (BI.Widget.current.$watchDelayCallbacks = []);

Loading…
Cancel
Save