Browse Source

KERNEL-13158: 优化useContext

es6
guy 2 years ago
parent
commit
1411131bae
  1. 3
      src/base/combination/navigation.js
  2. 2
      src/core/4.widget.js

3
src/base/combination/navigation.js

@ -43,9 +43,10 @@ BI.Navigation = BI.inherit(BI.Widget, {
return self.showIndex + v; return self.showIndex + v;
}, },
cardCreator: function (v) { cardCreator: function (v) {
BI.Widget.pushContext(self);
var card = o.cardCreator(v); var card = o.cardCreator(v);
BI.Widget.popContext();
self.cardMap[v] = card; self.cardMap[v] = card;
return card; return card;
}, },
afterCardCreated: BI.bind(this.afterCardCreated, this), afterCardCreated: BI.bind(this.afterCardCreated, this),

2
src/core/4.widget.js

@ -903,7 +903,7 @@
BI.useContext = function (inject) { BI.useContext = function (inject) {
// 通过组件找最近的store // 通过组件找最近的store
var vm = BI.Widget.findStore(BI.Widget.current); var vm = BI.Widget.findStore(BI.Widget.current || BI.Widget.context);
if (vm) { if (vm) {
if (inject) { if (inject) {
if (vm.$$computed && inject in vm.$$computed) { if (vm.$$computed && inject in vm.$$computed) {

Loading…
Cancel
Save