From 5e8a652ad951e6eac18365d19e3405202a002c0a Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 19 Oct 2022 17:49:11 +0800 Subject: [PATCH] update --- src/core/4.widget.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/core/4.widget.js b/src/core/4.widget.js index 4f91fd490..058015c32 100644 --- a/src/core/4.widget.js +++ b/src/core/4.widget.js @@ -903,14 +903,24 @@ BI.useContext = function (inject) { if (BI.Model.target) { - var p = BI.Model.target; + var vm = BI.Model.target; if (inject) { - while (p) { - if (p.$$context && inject in p.$$context) { - return p; + if (vm.$$computed && inject in vm.$$computed) { + return vm; + } + if (vm.$$state && inject in vm.$$state) { + return vm; + } + if (vm.$$model && inject in vm.$$model) { + return vm; + } + while (vm) { + if (vm.$$context && inject in vm.$$context) { + return vm; } - p = p._parent; + vm = vm._parent; } + return null; } } return BI.Model.target;