From 255d9dfc202693227f3a2e9232db0614e3f3b6d9 Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 8 Dec 2021 11:47:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81BI.useContext?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/4.widget.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/core/4.widget.js b/src/core/4.widget.js index f8fe45929..4a1212962 100644 --- a/src/core/4.widget.js +++ b/src/core/4.widget.js @@ -768,7 +768,18 @@ } }; - BI.useContext = function () { + BI.useContext = function (inject) { + if (BI.Model.target) { + var p = BI.Model.target; + if (inject) { + while (p) { + if (p.$$context && inject in p.$$context) { + return p; + } + p = p._parent; + } + } + } return BI.Model.target; };