{"id":93005,"date":"2026-08-11T16:49:32","date_gmt":"2026-08-11T08:49:32","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/93005.html"},"modified":"2026-08-11T16:49:32","modified_gmt":"2026-08-11T08:49:32","slug":"%e9%b8%bf%e8%92%996-1-arkui-uicontext-ui%e4%b8%8a%e4%b8%8b%e6%96%87%e5%9d%91%ef%bc%9arunscopedtask%e4%b8%8d%e6%98%afrunscopedonuithread","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/93005.html","title":{"rendered":"\u9e3f\u84996.1 arkui.UIContext UI\u4e0a\u4e0b\u6587\u5751\uff1arunScopedTask\u4e0d\u662frunScopedOnUiThread"},"content":{"rendered":"<p>\u672c\u6587\u662f\u300c\u9e3f\u8499 6.1 API 23 \u5f00\u53d1\u5751\u7cfb\u5217\u300d\u7b2c 4 \u7bc7&#xff08;ArkUI \u6876\u7b2c 4 \u7bc7&#xff09;\u3002\u672c\u7bc7\u8bb2 &#064;ohos.arkui.UIContext namespace&#xff08;API 10&#043;&#xff0c;\u9e3f\u8499 6.1 API 23 \u57fa\u5ea7&#xff09;\u2014\u2014UI \u4e0a\u4e0b\u6587 UIContext class &#043; 11 \u4e2a\u5b50\u7ba1\u7406\u5668 &#043; runScopedTask &#043; getFrameNodeById\u3002\u9e3f\u8499\u5751\u6839\u56e0&#xff1a;\u2460 runScopedTask(callback) \u662f UIContext \u5b9e\u4f8b\u65b9\u6cd5\u4e0d\u662f runScopedOnUiThread&#xff08;React runInNativeView vs \u9e3f\u8499 runScopedTask&#xff0c;UI \u64cd\u4f5c\u5fc5\u987b\u5728 UI \u7ebf\u7a0b&#xff09;&#xff1b;\u2461 getUIContext() \u662f\u7ec4\u4ef6\u65b9\u6cd5\u4e0d\u662f\u5168\u5c40\u51fd\u6570&#xff08;this.getUIContext() \u4e0d\u662f getUIContext()&#xff09;&#xff1b;\u2462 UIContext \u6709 11 \u4e2a\u5b50\u7ba1\u7406\u5668&#xff08;getFont\/getMediaQuery\/getRouter\/getPromptAction\/getComponentUtils\/getUIObserver\/getOverlayManager\/getDragController\/getMeasureUtils\/getFocusController\/getAtomicServiceBar&#xff09;&#xff1b;\u2463 getFrameNodeById(id) \u8fd4\u56de FrameNode | null \u4e0d\u662f FrameNode&#xff1b;\u2464 getFilteredInspectorTree(filters?) \u8fd4\u56de string&#xff08;JSON \u5b57\u7b26\u4e32&#xff09;\u4e0d\u662f object\u3002<\/p>\n<h3>\u4e00\u3001\u5f00\u7bc7&#xff1a;\u9e3f\u8499 UIContext \u4e0d\u662f React useContext&#xff0c;\u662f\u300c11 \u4e2a\u5b50\u7ba1\u7406\u5668\u7684 UI \u4e0a\u4e0b\u6587\u300d<\/h3>\n<p>\u4f60\u5199 React \u65f6&#xff0c;UI \u4e0a\u4e0b\u6587\u7528 useContext&#xff08;\u8fd4\u56de context value&#xff0c;\u65e0\u5b50\u7ba1\u7406\u5668&#xff09;&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ React useContext&#xff1a;\u8fd4\u56de context value&#xff08;\u65e0\u5b50\u7ba1\u7406\u5668&#xff09;<\/span><br \/>\n<span class=\"token keyword\">const<\/span> uiContext <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">useContext<\/span><span class=\"token punctuation\">(<\/span>UIContext<span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ \u274c React useContext \u8fd4\u56de context value&#xff0c;\u65e0\u5b50\u7ba1\u7406\u5668<\/span><br \/>\n<span class=\"token keyword\">const<\/span> <span class=\"token function-variable function\">showToast<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> promptAction<span class=\"token punctuation\">.<\/span><span class=\"token function\">showToast<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ \u274c React promptAction \u662f\u5168\u5c40\u51fd\u6570\u4e0d\u662f\u5b50\u7ba1\u7406\u5668<\/span><\/p>\n<p>\u4f60\u5199\u9e3f\u8499 ArkTS \u65f6&#xff0c;UI \u4e0a\u4e0b\u6587\u7528 UIContext class&#xff08;11 \u4e2a\u5b50\u7ba1\u7406\u5668 &#043; runScopedTask&#xff09;&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ ArkTS UIContext&#xff1a;class \u6709 11 \u4e2a\u5b50\u7ba1\u7406\u5668 &#043; runScopedTask&#xff08;UI \u7ebf\u7a0b\u8dd1 callback&#xff09;<\/span><br \/>\n<span class=\"token keyword\">import<\/span> <span class=\"token punctuation\">{<\/span> UIContext<span class=\"token punctuation\">,<\/span> Font<span class=\"token punctuation\">,<\/span> MediaQuery<span class=\"token punctuation\">,<\/span> Router<span class=\"token punctuation\">,<\/span> PromptAction <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">from<\/span> <span class=\"token string\">&#039;&#064;ohos.arkui.UIContext&#039;<\/span><\/p>\n<p><span class=\"token keyword\">const<\/span> uiContext<span class=\"token operator\">:<\/span> UIContext <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">getUIContext<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ \u2705 this.getUIContext() \u7ec4\u4ef6\u65b9\u6cd5\u53d6 UIContext \u5b9e\u4f8b<\/span><br \/>\n<span class=\"token comment\">\/\/ \u2705 UIContext \u6709 11 \u4e2a\u5b50\u7ba1\u7406\u5668&#xff08;getFont\/getMediaQuery\/getRouter\/getPromptAction \u7b49&#xff09;<\/span><br \/>\n<span class=\"token keyword\">const<\/span> fontManager<span class=\"token operator\">:<\/span> Font <span class=\"token operator\">&#061;<\/span> uiContext<span class=\"token punctuation\">.<\/span><span class=\"token function\">getFont<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ \u2705 getFont() \u53d6 Font \u5b50\u7ba1\u7406\u5668<\/span><br \/>\n<span class=\"token keyword\">const<\/span> routerManager<span class=\"token operator\">:<\/span> Router <span class=\"token operator\">&#061;<\/span> uiContext<span class=\"token punctuation\">.<\/span><span class=\"token function\">getRouter<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ \u2705 getRouter() \u53d6 Router \u5b50\u7ba1\u7406\u5668<\/span><br \/>\n<span class=\"token keyword\">const<\/span> promptAction<span class=\"token operator\">:<\/span> PromptAction <span class=\"token operator\">&#061;<\/span> uiContext<span class=\"token punctuation\">.<\/span><span class=\"token function\">getPromptAction<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ \u2705 getPromptAction() \u53d6 PromptAction \u5b50\u7ba1\u7406\u5668<\/span><br \/>\n<span class=\"token comment\">\/\/ \u2705 runScopedTask \u5728 UI \u7ebf\u7a0b\u8dd1 callback&#xff08;UI \u64cd\u4f5c\u5fc5\u987b\u5728 UI \u7ebf\u7a0b&#xff09;<\/span><br \/>\nuiContext<span class=\"token punctuation\">.<\/span><span class=\"token function\">runScopedTask<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token comment\">\/* UI \u64cd\u4f5c *\/<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token comment\">\/\/ \u9e3f\u8499\u5751\u6839\u56e0&#xff1a;UIContext \u6709 11 \u4e2a\u5b50\u7ba1\u7406\u5668&#xff0c;runScopedTask \u4e0d\u662f runScopedOnUiThread<\/span><\/p>\n<p>React useContext vs \u9e3f\u8499 UIContext \u7684\u533a\u522b&#xff1a;React \u628a UI \u4e0a\u4e0b\u6587\u5f53 context value&#xff08;useContext \u8fd4\u56de value&#xff0c;\u65e0\u5b50\u7ba1\u7406\u5668&#xff0c;promptAction \u662f\u5168\u5c40\u51fd\u6570&#xff09;&#xff0c;ArkTS \u628a UI \u4e0a\u4e0b\u6587\u5f53 class \u5b9e\u4f8b&#xff08;UIContext class \u6709 11 \u4e2a\u5b50\u7ba1\u7406\u5668&#xff0c;getFont\/getRouter\/getPromptAction \u7b49\u662f UIContext \u5b9e\u4f8b\u65b9\u6cd5\u4e0d\u662f\u5168\u5c40\u51fd\u6570&#xff0c;runScopedTask \u5728 UI \u7ebf\u7a0b\u8dd1 callback&#xff09;\u3002\u6839\u56e0\u4e0d\u662f context value \u662f class \u5b9e\u4f8b\u2014\u2014\u9e3f\u8499 UIContext \u6709 11 \u4e2a\u5b50\u7ba1\u7406\u5668&#xff0c;promptAction \u662f UIContext \u5b50\u7ba1\u7406\u5668\u4e0d\u662f\u5168\u5c40\u51fd\u6570\u3002<\/p>\n<h3>\u4e8c\u3001\u6839\u56e0&#xff1a;\u9e3f\u8499 arkui.UIContext \u7684\u4e94\u4e2a\u7ed1\u5b9a\u673a\u5236<\/h3>\n<p>\u9e3f\u8499 &#064;ohos.arkui.UIContext namespace&#xff08;API 10&#043;&#xff09;\u6838\u5fc3\u5bfc\u51fa UIContext class &#043; Font\/MediaQuery\/Router\/PromptAction\/ComponentUtils\/UIObserver\/OverlayManager\/DragController\/MeasureUtils\/FocusController \u7b49\u5b50\u7ba1\u7406\u5668\u3002<\/p>\n<h4>\u673a\u5236 1&#xff1a;runScopedTask \u662f UIContext \u5b9e\u4f8b\u65b9\u6cd5\u2014\u2014\u4e0d\u662f runScopedOnUiThread<\/h4>\n<p><span class=\"token comment\">\/\/ \u274c \u9e3f\u8499\u5751&#xff1a;runScopedOnUiThread \u4e0d\u5b58\u5728&#xff08;\u7f16\u8bd1\u9519 Property &#039;runScopedOnUiThread&#039; does not exist&#xff09;<\/span><br \/>\n<span class=\"token keyword\">const<\/span> uiContext<span class=\"token operator\">:<\/span> UIContext <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">getUIContext<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token comment\">\/\/ \u274c \u7f16\u8bd1\u9519&#xff1a;Property &#039;runScopedOnUiThread&#039; does not exist on type &#039;UIContext&#039;<\/span><br \/>\nuiContext<span class=\"token punctuation\">.<\/span><span class=\"token function\">runScopedOnUiThread<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token comment\">\/* UI \u64cd\u4f5c *\/<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ \u274c runScopedOnUiThread \u4e0d\u5b58\u5728<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u2705 \u6b63\u786e\u7528\u6cd5&#xff1a;runScopedTask(callback) \u662f UIContext \u5b9e\u4f8b\u65b9\u6cd5&#xff08;UI \u7ebf\u7a0b\u8dd1 callback&#xff09;<\/span><br \/>\nuiContext<span class=\"token punctuation\">.<\/span><span class=\"token function\">runScopedTask<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> <span class=\"token punctuation\">{<\/span>  <span class=\"token comment\">\/\/ \u2705 runScopedTask \u5728 UI \u7ebf\u7a0b\u8dd1 callback<\/span><br \/>\n  <span class=\"token comment\">\/\/ \u2705 UI \u64cd\u4f5c\u5fc5\u987b\u5728 UI \u7ebf\u7a0b&#xff08;runScopedTask \u4fdd\u8bc1 UI \u7ebf\u7a0b\u6267\u884c&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token comment\">\/\/ \u9e3f\u8499\u5751\u6839\u56e0&#xff1a;runScopedTask \u4e0d\u662f runScopedOnUiThread\u2014\u2014React runInNativeView vs \u9e3f\u8499 runScopedTask<\/span><\/p>\n<p>runScopedTask \u5751\u6839\u56e0&#xff1a;UIContext.runScopedTask(callback: () &#061;&gt; void): void \u662f UIContext \u5b9e\u4f8b\u65b9\u6cd5&#xff08;\u5728 UI \u7ebf\u7a0b\u8dd1 callback&#xff09;&#xff0c;\u4e0d\u662f runScopedOnUiThread&#xff08;\u9e3f\u8499 SDK \u65e0\u6b64\u65b9\u6cd5\u540d&#xff0c;\u89e6\u53d1 Property &#039;runScopedOnUiThread&#039; does not exist on type &#039;UIContext&#039; \u7f16\u8bd1\u9519&#xff09;\u3002\u9e3f\u8499\u5751&#xff1a;React runInNativeView vs \u9e3f\u8499 runScopedTask\u2014\u2014\u9e3f\u8499 UI \u7ebf\u7a0b\u8dd1 callback \u7528 runScopedTask\u3002<\/p>\n<h4>\u673a\u5236 2&#xff1a;getUIContext \u662f\u7ec4\u4ef6\u65b9\u6cd5\u4e0d\u662f\u5168\u5c40\u51fd\u6570\u2014\u2014this.getUIContext() \u4e0d\u662f getUIContext()<\/h4>\n<p><span class=\"token comment\">\/\/ \u274c \u9e3f\u8499\u5751&#xff1a;getUIContext() \u5168\u5c40\u51fd\u6570\u8c03\u7528\u7f16\u8bd1\u9519&#xff08;Cannot find name &#039;getUIContext&#039;&#xff09;<\/span><br \/>\n<span class=\"token comment\">\/\/ \u274c \u7f16\u8bd1\u9519&#xff1a;Cannot find name &#039;getUIContext&#039;<\/span><br \/>\n<span class=\"token keyword\">const<\/span> uiContext <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">getUIContext<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ \u274c getUIContext \u4e0d\u662f\u5168\u5c40\u51fd\u6570<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u2705 \u6b63\u786e\u7528\u6cd5&#xff1a;this.getUIContext()\u2014\u2014\u7ec4\u4ef6\u5b9e\u4f8b\u65b9\u6cd5<\/span><br \/>\n<span class=\"token decorator\"><span class=\"token at operator\">&#064;<\/span><span class=\"token function\">Entry<\/span><\/span><br \/>\n<span class=\"token decorator\"><span class=\"token at operator\">&#064;<\/span><span class=\"token function\">Component<\/span><\/span><br \/>\nstruct Index <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token function\">demonstrate<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u2705 this.getUIContext() \u662f\u7ec4\u4ef6\u65b9\u6cd5&#xff08;\u4e0d\u662f\u5168\u5c40\u51fd\u6570 getUIContext()&#xff09;<\/span><br \/>\n    <span class=\"token keyword\">const<\/span> uiContext<span class=\"token operator\">:<\/span> UIContext <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">getUIContext<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ \u2705 \u7ec4\u4ef6\u65b9\u6cd5\u83b7\u53d6 UIContext \u5b9e\u4f8b<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token comment\">\/\/ \u9e3f\u8499\u5751\u6839\u56e0&#xff1a;getUIContext \u662f\u7ec4\u4ef6\u65b9\u6cd5\u4e0d\u662f\u5168\u5c40\u51fd\u6570&#xff0c;\u5fc5\u987b this.getUIContext()<\/span><\/p>\n<p>getUIContext \u5751\u6839\u56e0&#xff1a;getUIContext(): UIContext \u662f\u7ec4\u4ef6\u5b9e\u4f8b\u65b9\u6cd5&#xff08;\u5728 ets\/component\/common.d.ts \u7684 Component \u58f0\u660e\u91cc&#xff09;&#xff0c;\u4e0d\u662f\u5168\u5c40\u51fd\u6570&#xff08;getUIContext() \u89e6\u53d1 Cannot find name &#039;getUIContext&#039; \u7f16\u8bd1\u9519&#xff09;\u3002\u53e6\u5916 &#064;ohos.window \u7684 window \u5b9e\u4f8b\u4e5f\u6709 getUIContext(): UIContext \u65b9\u6cd5&#xff08;window \u5b9e\u4f8b\u65b9\u6cd5&#xff0c;\u4e0d\u662f\u5168\u5c40\u51fd\u6570&#xff09;\u3002<\/p>\n<h4>\u673a\u5236 3&#xff1a;UIContext \u6709 11 \u4e2a\u5b50\u7ba1\u7406\u5668\u2014\u2014getFont\/getMediaQuery\/getRouter\/getPromptAction \u7b49<\/h4>\n<p><span class=\"token comment\">\/\/ \u2705 UIContext \u7684 11 \u4e2a\u5b50\u7ba1\u7406\u5668&#xff08;\u6bcf\u4e2a\u662f UIContext \u5b9e\u4f8b\u65b9\u6cd5\u4e0d\u662f\u5168\u5c40\u51fd\u6570&#xff09;<\/span><br \/>\n<span class=\"token keyword\">const<\/span> uiContext<span class=\"token operator\">:<\/span> UIContext <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">getUIContext<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u2705 11 \u4e2a\u5b50\u7ba1\u7406\u5668&#xff08;UIContext \u5b9e\u4f8b\u65b9\u6cd5&#xff0c;\u4e0d\u662f\u5168\u5c40\u51fd\u6570&#xff09;<\/span><br \/>\n<span class=\"token keyword\">const<\/span> fontManager<span class=\"token operator\">:<\/span> Font <span class=\"token operator\">&#061;<\/span> uiContext<span class=\"token punctuation\">.<\/span><span class=\"token function\">getFont<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ \u2705 getFont() \u53d6 Font \u5b50\u7ba1\u7406\u5668<\/span><br \/>\n<span class=\"token keyword\">const<\/span> mediaQuery<span class=\"token operator\">:<\/span> MediaQuery <span class=\"token operator\">&#061;<\/span> uiContext<span class=\"token punctuation\">.<\/span><span class=\"token function\">getMediaQuery<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ \u2705 getMediaQuery() \u53d6 MediaQuery \u5b50\u7ba1\u7406\u5668<\/span><br \/>\n<span class=\"token keyword\">const<\/span> routerManager<span class=\"token operator\">:<\/span> Router <span class=\"token operator\">&#061;<\/span> uiContext<span class=\"token punctuation\">.<\/span><span class=\"token function\">getRouter<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ \u2705 getRouter() \u53d6 Router \u5b50\u7ba1\u7406\u5668<\/span><br \/>\n<span class=\"token keyword\">const<\/span> promptAction<span class=\"token operator\">:<\/span> PromptAction <span class=\"token operator\">&#061;<\/span> uiContext<span class=\"token punctuation\">.<\/span><span class=\"token function\">getPromptAction<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ \u2705 getPromptAction() \u53d6 PromptAction \u5b50\u7ba1\u7406\u5668<\/span><br \/>\n<span class=\"token comment\">\/\/ \u2705 \u8fd8\u6709 7 \u4e2a\u5b50\u7ba1\u7406\u5668&#xff1a;getComponentUtils\/getUIObserver\/getOverlayManager\/getDragController\/getMeasureUtils\/getFocusController\/getAtomicServiceBar<\/span><br \/>\n<span class=\"token comment\">\/\/ \u9e3f\u8499\u5751\u6839\u56e0&#xff1a;UIContext \u6709 11 \u4e2a\u5b50\u7ba1\u7406\u5668&#xff0c;\u6bcf\u4e2a\u662f UIContext \u5b9e\u4f8b\u65b9\u6cd5\u4e0d\u662f\u5168\u5c40\u51fd\u6570<\/span><\/p>\n<p>11 \u4e2a\u5b50\u7ba1\u7406\u5668\u5751\u6839\u56e0&#xff1a;UIContext class \u6709 11 \u4e2a\u5b50\u7ba1\u7406\u5668\u5b9e\u4f8b\u65b9\u6cd5&#xff1a;getFont(): Font&#xff08;API 10&#043;&#xff0c;\u5b57\u4f53\u7ba1\u7406\u5668&#xff09;\u3001getMediaQuery(): MediaQuery&#xff08;API 10&#043;&#xff0c;\u5a92\u4f53\u67e5\u8be2&#xff09;\u3001getRouter(): Router&#xff08;API 10&#043;&#xff0c;\u8def\u7531\u7ba1\u7406\u5668&#xff09;\u3001getPromptAction(): PromptAction&#xff08;API 10&#043;&#xff0c;\u5f39\u7a97\u7ba1\u7406\u5668&#xff09;\u3001getComponentUtils(): ComponentUtils&#xff08;API 10&#043;&#xff0c;\u7ec4\u4ef6\u5de5\u5177&#xff09;\u3001getUIObserver(): UIObserver&#xff08;API 10&#043;&#xff0c;UI \u89c2\u5bdf\u5668&#xff09;\u3001getOverlayManager(): OverlayManager&#xff08;API 11&#043;&#xff0c;\u6d6e\u5c42\u7ba1\u7406\u5668&#xff09;\u3001getDragController(): DragController&#xff08;API 11&#043;&#xff0c;\u62d6\u62fd\u7ba1\u7406\u5668&#xff09;\u3001getMeasureUtils(): MeasureUtils&#xff08;API 12&#043;&#xff0c;\u6d4b\u91cf\u5de5\u5177&#xff09;\u3001getFocusController(): FocusController&#xff08;API 12&#043;&#xff0c;\u7126\u70b9\u7ba1\u7406\u5668&#xff09;\u3001getAtomicServiceBar(): Nullable&lt;AtomicServiceBar&gt;&#xff08;API 12&#043;&#xff0c;\u539f\u5b50\u5316\u670d\u52a1\u680f&#xff09;\u3002\u9e3f\u8499\u5751&#xff1a;\u6bcf\u4e2a\u5b50\u7ba1\u7406\u5668\u662f UIContext \u5b9e\u4f8b\u65b9\u6cd5\u4e0d\u662f\u5168\u5c40\u51fd\u6570\u2014\u2014React promptAction \u662f\u5168\u5c40\u51fd\u6570&#xff0c;\u9e3f\u8499 promptAction \u662f UIContext \u5b50\u7ba1\u7406\u5668\u3002<\/p>\n<h4>\u673a\u5236 4&#xff1a;getFrameNodeById \u8fd4\u56de FrameNode | null\u2014\u2014\u4e0d\u662f FrameNode<\/h4>\n<p><span class=\"token comment\">\/\/ \u2705 getFrameNodeById(id): FrameNode | null\u2014\u2014\u901a\u8fc7\u7ec4\u4ef6 id \u53d6 FrameNode&#xff08;\u8fd4\u56de | null&#xff09;<\/span><br \/>\n<span class=\"token keyword\">const<\/span> uiContext<span class=\"token operator\">:<\/span> UIContext <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">getUIContext<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token comment\">\/\/ \u2705 getFrameNodeById \u8fd4\u56de FrameNode | null&#xff08;\u4e0d\u662f FrameNode&#xff0c;\u627e\u4e0d\u5230\u8fd4\u56de null&#xff09;<\/span><br \/>\n<span class=\"token keyword\">const<\/span> frameNode<span class=\"token operator\">:<\/span> FrameNode <span class=\"token operator\">|<\/span> <span class=\"token keyword\">null<\/span> <span class=\"token operator\">&#061;<\/span> uiContext<span class=\"token punctuation\">.<\/span><span class=\"token function\">getFrameNodeById<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;snapshotTarget&#039;<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ \u2705 \u8fd4\u56de FrameNode | null<\/span><br \/>\n<span class=\"token comment\">\/\/ \u2705 \u627e\u4e0d\u5230\u7ec4\u4ef6 id \u8fd4\u56de null&#xff08;\u4e0d\u662f throw \u9519&#xff0c;\u4e0d\u662f undefined&#xff09;<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>frameNode <span class=\"token operator\">!&#061;&#061;<\/span> <span class=\"token keyword\">null<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token comment\">\/\/ \u2705 frameNode \u662f FrameNode \u5b9e\u4f8b&#xff08;getFrameNodeById \u627e\u5230\u7ec4\u4ef6 id&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token comment\">\/\/ \u9e3f\u8499\u5751\u6839\u56e0&#xff1a;getFrameNodeById \u8fd4\u56de FrameNode | null&#xff0c;\u627e\u4e0d\u5230\u8fd4\u56de null \u4e0d\u662f undefined<\/span><\/p>\n<p>getFrameNodeById \u5751\u6839\u56e0&#xff1a;UIContext.getFrameNodeById(id: string): FrameNode | null&#xff08;API 11&#043;&#xff09;\u901a\u8fc7\u7ec4\u4ef6 id \u53d6 FrameNode&#xff0c;\u8fd4\u56de FrameNode | null&#xff08;\u4e0d\u662f FrameNode&#xff0c;\u627e\u4e0d\u5230\u7ec4\u4ef6 id \u8fd4\u56de null \u4e0d\u662f undefined&#xff0c;\u4e0d\u662f throw \u9519&#xff09;\u3002\u9e3f\u8499\u5751&#xff1a;getFrameNodeById \u8fd4\u56de FrameNode | null&#xff0c;\u8d4b\u7ed9 FrameNode \u4f1a\u89e6\u53d1 Type &#039;FrameNode | null&#039; is not assignable to type &#039;FrameNode&#039; \u7f16\u8bd1\u9519\u2014\u2014\u5fc5\u987b\u7528 FrameNode | null \u63a5\u6536 &#043; null \u68c0\u67e5\u3002<\/p>\n<h4>\u673a\u5236 5&#xff1a;getFilteredInspectorTree \u8fd4\u56de string&#xff08;JSON&#xff09;\u2014\u2014\u4e0d\u662f object<\/h4>\n<p><span class=\"token comment\">\/\/ \u2705 getFilteredInspectorTree(filters?): string\u2014\u2014\u53d6\u7ec4\u4ef6\u6811 JSON string \u4e0d\u662f object<\/span><br \/>\n<span class=\"token keyword\">const<\/span> uiContext<span class=\"token operator\">:<\/span> UIContext <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">getUIContext<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token comment\">\/\/ \u2705 getFilteredInspectorTree \u8fd4\u56de string&#xff08;JSON \u5b57\u7b26\u4e32&#xff0c;\u4e0d\u662f object&#xff09;<\/span><br \/>\n<span class=\"token keyword\">const<\/span> inspectorTree<span class=\"token operator\">:<\/span> <span class=\"token builtin\">string<\/span> <span class=\"token operator\">&#061;<\/span> uiContext<span class=\"token punctuation\">.<\/span><span class=\"token function\">getFilteredInspectorTree<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ \u2705 \u8fd4\u56de string \u4e0d\u662f object<\/span><br \/>\n<span class=\"token comment\">\/\/ \u2705 \u8981\u7528 JSON.parse(inspectorTree) \u8f6c object&#xff08;getFilteredInspectorTree \u76f4\u63a5\u8fd4\u56de JSON \u5b57\u7b26\u4e32&#xff09;<\/span><br \/>\n<span class=\"token keyword\">const<\/span> treeObject<span class=\"token operator\">:<\/span> object <span class=\"token operator\">&#061;<\/span> <span class=\"token constant\">JSON<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">parse<\/span><span class=\"token punctuation\">(<\/span>inspectorTree<span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ \u2705 JSON.parse \u8f6c object<\/span><br \/>\n<span class=\"token comment\">\/\/ \u9e3f\u8499\u5751\u6839\u56e0&#xff1a;getFilteredInspectorTree \u8fd4\u56de string&#xff08;JSON \u5b57\u7b26\u4e32&#xff09;&#xff0c;\u4e0d\u662f object<\/span><\/p>\n<p>getFilteredInspectorTree \u5751\u6839\u56e0&#xff1a;UIContext.getFilteredInspectorTree(filters?: Array&lt;string&gt;): string&#xff08;API 12&#043;&#xff09;\u53d6\u7ec4\u4ef6\u6811 JSON \u5b57\u7b26\u4e32&#xff0c;\u8fd4\u56de string&#xff08;\u4e0d\u662f object&#xff09;\u3002\u9e3f\u8499\u5751&#xff1a;getFilteredInspectorTree \u76f4\u63a5\u8fd4\u56de JSON \u5b57\u7b26\u4e32&#xff08;\u4e0d\u662f object&#xff09;&#xff0c;\u8981\u7528 JSON.parse(inspectorTree) \u8f6c object\u2014\u2014React DevTools \u7ec4\u4ef6\u6811\u662f object&#xff0c;\u9e3f\u8499 getFilteredInspectorTree \u662f JSON \u5b57\u7b26\u4e32\u3002<\/p>\n<h3>\u4e09\u3001\u771f\u673a\u914d\u56fe&#xff1a;\u9e3f\u8499 arkui.UIContext UI \u4e0a\u4e0b\u6587\u5751\u2014\u2014runScopedTask &#043; 11 \u4e2a\u5b50\u7ba1\u7406\u5668<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260811084924-6a7ae21453560.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260811084926-6a7ae2160595e.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260811084927-6a7ae217eb920.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260811084929-6a7ae2199f582.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u771f\u673a\u914d\u56fe\u5c55\u793a&#xff1a;<\/p>\n<ul>\n<li>\u521d\u59cb\u6001&#xff1a;\u9e3f\u8499 6.1 arkui.UIContext UI \u4e0a\u4e0b\u6587\u5751\u6807\u9898&#xff0c;\u76ee\u6807\u7ec4\u4ef6&#xff08;\u7ea2\u6846 id&#061;snapshotTarget&#xff09;&#xff0c;\u573a\u666f1~7 \u5361\u7247&#xff0c;\u8981\u70b9\u8bf4\u660e<\/li>\n<li>getUIContext \u9a8c\u8bc1\u6001&#xff1a;\u70b9\u51fb\u300c\u2460 \u9a8c\u8bc1 getUIContext\u300d\u6309\u94ae&#xff0c;\u663e\u793a\u300c\u2705 getUIContext() \u662f\u7ec4\u4ef6\u65b9\u6cd5\u4e0d\u662f\u5168\u5c40\u51fd\u6570\u300d<\/li>\n<li>runScopedTask \u9a8c\u8bc1\u6001&#xff1a;\u70b9\u51fb\u300c\u2461 \u9a8c\u8bc1 runScopedTask\u300d\u6309\u94ae&#xff0c;\u663e\u793a\u300c\u2705 runScopedTask \u5728 UI \u7ebf\u7a0b\u8dd1 callback \u9a8c\u8bc1\u6210\u529f\u300d<\/li>\n<li>11 \u4e2a\u5b50\u7ba1\u7406\u5668\u9a8c\u8bc1\u6001&#xff1a;\u70b9\u51fb\u300c\u2462 \u9a8c\u8bc1 getFont\u300d&#043;\u300c\u2463 \u9a8c\u8bc1 getMediaQuery\u300d&#043;\u300c\u2464 \u9a8c\u8bc1 getRouter &#043; getPromptAction\u300d\u6309\u94ae&#xff0c;\u663e\u793a\u300c\u2705 getFont\/getMediaQuery\/getRouter\/getPromptAction \u5b50\u7ba1\u7406\u5668\u9a8c\u8bc1\u6210\u529f\u300d<\/li>\n<li>getFrameNodeById &#043; getFilteredInspectorTree \u6001&#xff1a;\u70b9\u51fb\u300c\u2466 \u9a8c\u8bc1 getFrameNodeById\u300d&#043;\u300c\u2467 \u9a8c\u8bc1 getFilteredInspectorTree\u300d\u6309\u94ae&#xff0c;\u663e\u793a\u300c\u2705 getFrameNodeById(\u201cid\u201d) \u53d6 FrameNode | null \u9a8c\u8bc1\u6210\u529f\u300d&#043;\u300c\u2705 getFilteredInspectorTree() \u53d6\u7ec4\u4ef6\u6811 JSON \u9a8c\u8bc1\u6210\u529f\u300d<\/li>\n<\/ul>\n<h3>\u56db\u3001\u771f\u89e3\u6cd5&#xff1a;\u9e3f\u8499 arkui.UIContext \u7684\u56db\u4e2a\u573a\u666f<\/h3>\n<h4>\u573a\u666f 1&#xff1a;getUIContext &#043; runScopedTask\u2014\u201490% \u573a\u666f\u9996\u9009<\/h4>\n<p><span class=\"token keyword\">import<\/span> <span class=\"token punctuation\">{<\/span> UIContext <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">from<\/span> <span class=\"token string\">&#039;&#064;ohos.arkui.UIContext&#039;<\/span><\/p>\n<p><span class=\"token decorator\"><span class=\"token at operator\">&#064;<\/span><span class=\"token function\">Entry<\/span><\/span><br \/>\n<span class=\"token decorator\"><span class=\"token at operator\">&#064;<\/span><span class=\"token function\">Component<\/span><\/span><br \/>\nstruct Index <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token function\">demonstrateScopedTask<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u2705 this.getUIContext() \u7ec4\u4ef6\u65b9\u6cd5\u53d6 UIContext \u5b9e\u4f8b&#xff08;\u4e0d\u662f\u5168\u5c40\u51fd\u6570 getUIContext()&#xff09;<\/span><br \/>\n    <span class=\"token keyword\">const<\/span> uiContext<span class=\"token operator\">:<\/span> UIContext <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">getUIContext<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ \u2705 \u7ec4\u4ef6\u65b9\u6cd5<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u2705 runScopedTask \u5728 UI \u7ebf\u7a0b\u8dd1 callback&#xff08;UI \u64cd\u4f5c\u5fc5\u987b\u5728 UI \u7ebf\u7a0b&#xff09;<\/span><br \/>\n    uiContext<span class=\"token punctuation\">.<\/span><span class=\"token function\">runScopedTask<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> <span class=\"token punctuation\">{<\/span>  <span class=\"token comment\">\/\/ \u2705 runScopedTask \u4e0d\u662f runScopedOnUiThread<\/span><br \/>\n      <span class=\"token comment\">\/\/ \u2705 UI \u64cd\u4f5c&#xff08;Text\/Button \u7b49\u7ec4\u4ef6\u64cd\u4f5c\u5fc5\u987b\u5728 UI \u7ebf\u7a0b&#xff09;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n  <span class=\"token function\">build<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token function\">Column<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span> space<span class=\"token operator\">:<\/span> <span class=\"token number\">8<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token function\">Text<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;demo&#039;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">}<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token comment\">\/\/ getUIContext &#043; runScopedTask&#xff1a;90% \u573a\u666f\u9996\u9009&#xff0c;this.getUIContext() \u7ec4\u4ef6\u65b9\u6cd5 &#043; runScopedTask UI \u7ebf\u7a0b\u8dd1<\/span><\/p>\n<p>\u9e3f\u8499 arkui.UIContext API \u771f\u540d\u5751&#xff1a;import { UIContext, Font, MediaQuery, Router, PromptAction } from &#039;&#064;ohos.arkui.UIContext&#039;&#xff08;named import&#xff09;&#xff1b;UIContext \u662f export declare class&#xff08;API 10&#043;&#xff09;&#xff1b;getUIContext(): UIContext \u662f\u7ec4\u4ef6\u65b9\u6cd5&#xff08;this.getUIContext()&#xff09;&#xff1b;runScopedTask(callback: () &#061;&gt; void): void \u662f UIContext \u5b9e\u4f8b\u65b9\u6cd5&#xff08;\u4e0d\u662f runScopedOnUiThread&#xff09;&#xff1b;SysCap SystemCapability.ArkUI.ArkUI.Full&#xff1b;&#064;crossplatform &#064;atomicservice\u3002<\/p>\n<h4>\u573a\u666f 2&#xff1a;11 \u4e2a\u5b50\u7ba1\u7406\u5668\u2014\u2014getFont\/getMediaQuery\/getRouter\/getPromptAction<\/h4>\n<p><span class=\"token keyword\">import<\/span> <span class=\"token punctuation\">{<\/span> UIContext<span class=\"token punctuation\">,<\/span> Font<span class=\"token punctuation\">,<\/span> MediaQuery<span class=\"token punctuation\">,<\/span> Router<span class=\"token punctuation\">,<\/span> PromptAction <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">from<\/span> <span class=\"token string\">&#039;&#064;ohos.arkui.UIContext&#039;<\/span><\/p>\n<p><span class=\"token keyword\">const<\/span> uiContext<span class=\"token operator\">:<\/span> UIContext <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">getUIContext<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u2705 11 \u4e2a\u5b50\u7ba1\u7406\u5668&#xff08;UIContext \u5b9e\u4f8b\u65b9\u6cd5&#xff0c;\u4e0d\u662f\u5168\u5c40\u51fd\u6570&#xff09;<\/span><br \/>\n<span class=\"token keyword\">const<\/span> fontManager<span class=\"token operator\">:<\/span> Font <span class=\"token operator\">&#061;<\/span> uiContext<span class=\"token punctuation\">.<\/span><span class=\"token function\">getFont<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ API 10&#043; Font&#xff08;registerFont\/getSystemFontList&#xff09;<\/span><br \/>\n<span class=\"token keyword\">const<\/span> mediaQuery<span class=\"token operator\">:<\/span> MediaQuery <span class=\"token operator\">&#061;<\/span> uiContext<span class=\"token punctuation\">.<\/span><span class=\"token function\">getMediaQuery<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ API 10&#043; MediaQuery&#xff08;match\/orientation&#xff09;<\/span><br \/>\n<span class=\"token keyword\">const<\/span> routerManager<span class=\"token operator\">:<\/span> Router <span class=\"token operator\">&#061;<\/span> uiContext<span class=\"token punctuation\">.<\/span><span class=\"token function\">getRouter<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ API 10&#043; Router&#xff08;push\/replace\/back&#xff09;<\/span><br \/>\n<span class=\"token keyword\">const<\/span> promptAction<span class=\"token operator\">:<\/span> PromptAction <span class=\"token operator\">&#061;<\/span> uiContext<span class=\"token punctuation\">.<\/span><span class=\"token function\">getPromptAction<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ API 10&#043; PromptAction&#xff08;showToast\/showDialog&#xff09;<\/span><br \/>\n<span class=\"token comment\">\/\/ \u2705 \u8fd8\u6709 7 \u4e2a\u5b50\u7ba1\u7406\u5668&#xff1a;<\/span><br \/>\n<span class=\"token comment\">\/\/ uiContext.getComponentUtils(): ComponentUtils  \/\/ API 10&#043; \u7ec4\u4ef6\u5de5\u5177<\/span><br \/>\n<span class=\"token comment\">\/\/ uiContext.getUIObserver(): UIObserver  \/\/ API 10&#043; UI \u89c2\u5bdf\u5668<\/span><br \/>\n<span class=\"token comment\">\/\/ uiContext.getOverlayManager(): OverlayManager  \/\/ API 11&#043; \u6d6e\u5c42\u7ba1\u7406\u5668<\/span><br \/>\n<span class=\"token comment\">\/\/ uiContext.getDragController(): DragController  \/\/ API 11&#043; \u62d6\u62fd\u7ba1\u7406\u5668<\/span><br \/>\n<span class=\"token comment\">\/\/ uiContext.getMeasureUtils(): MeasureUtils  \/\/ API 12&#043; \u6d4b\u91cf\u5de5\u5177<\/span><br \/>\n<span class=\"token comment\">\/\/ uiContext.getFocusController(): FocusController  \/\/ API 12&#043; \u7126\u70b9\u7ba1\u7406\u5668<\/span><br \/>\n<span class=\"token comment\">\/\/ uiContext.getAtomicServiceBar(): Nullable&lt;AtomicServiceBar&gt;  \/\/ API 12&#043; \u539f\u5b50\u5316\u670d\u52a1\u680f<\/span><br \/>\n<span class=\"token comment\">\/\/ 11 \u4e2a\u5b50\u7ba1\u7406\u5668&#xff1a;\u6bcf\u4e2a\u662f UIContext \u5b9e\u4f8b\u65b9\u6cd5\u4e0d\u662f\u5168\u5c40\u51fd\u6570<\/span><\/p>\n<p>\u9e3f\u8499 11 \u4e2a\u5b50\u7ba1\u7406\u5668 API \u771f\u540d\u5751&#xff1a;getFont(): Font&#xff08;API 10&#043;&#xff0c;registerFont\/getSystemFontList\/getFontByName&#xff09;&#xff1b;getMediaQuery(): MediaQuery&#xff08;API 10&#043;&#xff0c;match\/on(&#039;change&#039;)&#xff09;&#xff1b;getRouter(): Router&#xff08;API 10&#043;&#xff0c;push\/replace\/back\/getState&#xff09;&#xff1b;getPromptAction(): PromptAction&#xff08;API 10&#043;&#xff0c;showToast\/showDialog\/showActionMenu&#xff09;&#xff1b;getComponentUtils(): ComponentUtils&#xff08;API 10&#043;&#xff0c;getRectangleById&#xff09;&#xff1b;getUIObserver(): UIObserver&#xff08;API 10&#043;&#xff0c;on(&#039;scroll&#039;)\/on(&#039;willScroll&#039;)&#xff09;&#xff1b;getOverlayManager(): OverlayManager&#xff08;API 11&#043;&#xff09;&#xff1b;getDragController(): DragController&#xff08;API 11&#043;&#xff09;&#xff1b;getMeasureUtils(): MeasureUtils&#xff08;API 12&#043;&#xff09;&#xff1b;getFocusController(): FocusController&#xff08;API 12&#043;&#xff09;&#xff1b;getAtomicServiceBar(): Nullable&lt;AtomicServiceBar&gt;&#xff08;API 12&#043;&#xff0c;\u8fd4\u56de Nullable \u53ef\u80fd null&#xff09;&#xff1b;\u9e3f\u8499\u5751&#xff1a;\u6bcf\u4e2a\u5b50\u7ba1\u7406\u5668\u662f UIContext \u5b9e\u4f8b\u65b9\u6cd5\u4e0d\u662f\u5168\u5c40\u51fd\u6570\u2014\u2014React promptAction \u662f\u5168\u5c40\u51fd\u6570&#xff0c;\u9e3f\u8499 promptAction \u662f UIContext \u5b50\u7ba1\u7406\u5668 uiContext.getPromptAction()\u3002<\/p>\n<h4>\u573a\u666f 3&#xff1a;getFrameNodeById\u2014\u2014\u901a\u8fc7\u7ec4\u4ef6 id \u53d6 FrameNode<\/h4>\n<p><span class=\"token keyword\">import<\/span> <span class=\"token punctuation\">{<\/span> UIContext <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">from<\/span> <span class=\"token string\">&#039;&#064;ohos.arkui.UIContext&#039;<\/span><br \/>\n<span class=\"token keyword\">import<\/span> <span class=\"token punctuation\">{<\/span> FrameNode <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">from<\/span> <span class=\"token string\">&#039;&#064;ohos.arkui.node&#039;<\/span><\/p>\n<p><span class=\"token keyword\">const<\/span> uiContext<span class=\"token operator\">:<\/span> UIContext <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">getUIContext<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token comment\">\/\/ \u2705 getFrameNodeById(id): FrameNode | null\u2014\u2014\u901a\u8fc7\u7ec4\u4ef6 id \u53d6 FrameNode&#xff08;\u8fd4\u56de | null&#xff09;<\/span><br \/>\n<span class=\"token keyword\">const<\/span> frameNode<span class=\"token operator\">:<\/span> FrameNode <span class=\"token operator\">|<\/span> <span class=\"token keyword\">null<\/span> <span class=\"token operator\">&#061;<\/span> uiContext<span class=\"token punctuation\">.<\/span><span class=\"token function\">getFrameNodeById<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;snapshotTarget&#039;<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ \u2705 \u8fd4\u56de FrameNode | null<\/span><br \/>\n<span class=\"token comment\">\/\/ \u2705 \u627e\u4e0d\u5230\u7ec4\u4ef6 id \u8fd4\u56de null&#xff08;\u4e0d\u662f throw \u9519&#xff0c;\u4e0d\u662f undefined&#xff09;<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>frameNode <span class=\"token operator\">!&#061;&#061;<\/span> <span class=\"token keyword\">null<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span>  <span class=\"token comment\">\/\/ \u2705 \u5fc5\u987b\u7528 FrameNode | null \u63a5\u6536 &#043; null \u68c0\u67e5<\/span><br \/>\n  <span class=\"token comment\">\/\/ \u2705 frameNode \u662f FrameNode \u5b9e\u4f8b&#xff08;\u53ef\u64cd\u4f5c RenderNode\/getRenderNode \u7b49&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token comment\">\/\/ getFrameNodeById&#xff1a;\u8fd4\u56de FrameNode | null&#xff0c;\u627e\u4e0d\u5230\u8fd4\u56de null \u4e0d\u662f undefined<\/span><\/p>\n<p>\u9e3f\u8499 getFrameNodeById API \u771f\u540d\u5751&#xff1a;getFrameNodeById(id: string): FrameNode | null&#xff08;API 11&#043;&#xff09;&#xff1b;\u8fd4\u56de FrameNode | null&#xff08;\u4e0d\u662f FrameNode&#xff0c;\u627e\u4e0d\u5230\u8fd4\u56de null \u4e0d\u662f undefined&#xff0c;\u4e0d\u662f throw \u9519&#xff09;&#xff1b;\u9e3f\u8499\u5751&#xff1a;\u8d4b\u7ed9 FrameNode \u4f1a\u89e6\u53d1 Type &#039;FrameNode | null&#039; is not assignable to type &#039;FrameNode&#039; \u7f16\u8bd1\u9519\u2014\u2014\u5fc5\u987b\u7528 FrameNode | null \u63a5\u6536 &#043; null \u68c0\u67e5\u3002<\/p>\n<h4>\u573a\u666f 4&#xff1a;getFilteredInspectorTree\u2014\u2014\u53d6\u7ec4\u4ef6\u6811 JSON \u5b57\u7b26\u4e32<\/h4>\n<p><span class=\"token keyword\">import<\/span> <span class=\"token punctuation\">{<\/span> UIContext <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">from<\/span> <span class=\"token string\">&#039;&#064;ohos.arkui.UIContext&#039;<\/span><\/p>\n<p><span class=\"token keyword\">const<\/span> uiContext<span class=\"token operator\">:<\/span> UIContext <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">getUIContext<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token comment\">\/\/ \u2705 getFilteredInspectorTree(filters?): string\u2014\u2014\u53d6\u7ec4\u4ef6\u6811 JSON \u5b57\u7b26\u4e32&#xff08;\u8fd4\u56de string \u4e0d\u662f object&#xff09;<\/span><br \/>\n<span class=\"token keyword\">const<\/span> inspectorTree<span class=\"token operator\">:<\/span> <span class=\"token builtin\">string<\/span> <span class=\"token operator\">&#061;<\/span> uiContext<span class=\"token punctuation\">.<\/span><span class=\"token function\">getFilteredInspectorTree<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ \u2705 \u8fd4\u56de string \u4e0d\u662f object<\/span><br \/>\n<span class=\"token comment\">\/\/ \u2705 \u8981\u7528 JSON.parse(inspectorTree) \u8f6c object&#xff08;getFilteredInspectorTree \u76f4\u63a5\u8fd4\u56de JSON \u5b57\u7b26\u4e32&#xff09;<\/span><br \/>\n<span class=\"token keyword\">const<\/span> treeObject<span class=\"token operator\">:<\/span> object <span class=\"token operator\">&#061;<\/span> <span class=\"token constant\">JSON<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">parse<\/span><span class=\"token punctuation\">(<\/span>inspectorTree<span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ \u2705 JSON.parse \u8f6c object<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u2705 getFilteredInspectorTreeById(id, depth, filters?): string\u2014\u2014\u6309 id &#043; depth \u53d6\u5b50\u6811 JSON<\/span><br \/>\n<span class=\"token keyword\">const<\/span> subTree<span class=\"token operator\">:<\/span> <span class=\"token builtin\">string<\/span> <span class=\"token operator\">&#061;<\/span> uiContext<span class=\"token punctuation\">.<\/span><span class=\"token function\">getFilteredInspectorTreeById<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;snapshotTarget&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ \u2705 \u6309 id &#043; depth&#061;3 \u53d6\u5b50\u6811<\/span><br \/>\n<span class=\"token comment\">\/\/ getFilteredInspectorTree&#xff1a;\u8fd4\u56de string&#xff08;JSON \u5b57\u7b26\u4e32&#xff09;&#xff0c;\u4e0d\u662f object<\/span><\/p>\n<p>\u9e3f\u8499 getFilteredInspectorTree API \u771f\u540d\u5751&#xff1a;getFilteredInspectorTree(filters?: Array&lt;string&gt;): string&#xff08;API 12&#043;&#xff09;\u53d6\u7ec4\u4ef6\u6811 JSON \u5b57\u7b26\u4e32&#xff0c;\u8fd4\u56de string&#xff08;\u4e0d\u662f object&#xff09;&#xff1b;getFilteredInspectorTreeById(id: string, depth: number, filters?: Array&lt;string&gt;): string&#xff08;API 12&#043;&#xff09;\u6309 id &#043; depth \u53d6\u5b50\u6811 JSON \u5b57\u7b26\u4e32&#xff1b;\u9e3f\u8499\u5751&#xff1a;\u76f4\u63a5\u8fd4\u56de JSON \u5b57\u7b26\u4e32&#xff08;\u4e0d\u662f object&#xff09;&#xff0c;\u8981\u7528 JSON.parse(inspectorTree) \u8f6c object\u2014\u2014React DevTools \u7ec4\u4ef6\u6811\u662f object&#xff0c;\u9e3f\u8499 getFilteredInspectorTree \u662f JSON \u5b57\u7b26\u4e32\u3002<\/p>\n<h3>\u4e94\u3001\u4e00\u53e5\u8bdd\u54f2\u5b66<\/h3>\n<p>\u5199\u9e3f\u8499 ArkUI \u8bb0\u4f4f&#xff1a;UIContext \u4e0d\u662f React useContext \u662f\u300c11 \u4e2a\u5b50\u7ba1\u7406\u5668\u7684 UI \u4e0a\u4e0b\u6587\u300d\u2014\u2014\u9e3f\u8499 6.1 API 23 &#064;ohos.arkui.UIContext namespace&#xff08;API 10&#043;&#xff0c;\u9e3f\u8499 6.1 API 23 \u57fa\u5ea7&#xff0c;UIContext class &#043; 11 \u4e2a\u5b50\u7ba1\u7406\u5668&#xff0c;SysCap SystemCapability.ArkUI.ArkUI.Full&#xff0c;&#064;crossplatform &#064;atomicservice&#xff09;\u3002\u6839\u56e0\u4e0d\u662f context value \u662f class \u5b9e\u4f8b\u2014\u2014runScopedTask(callback: () &#061;&gt; void): void \u662f UIContext \u5b9e\u4f8b\u65b9\u6cd5&#xff08;\u274c \u4e0d\u662f runScopedOnUiThread&#xff0c;\u2705 UI \u7ebf\u7a0b\u8dd1 callback&#xff0c;React runInNativeView vs \u9e3f\u8499 runScopedTask&#xff09;&#xff0c;getUIContext(): UIContext \u662f\u7ec4\u4ef6\u65b9\u6cd5&#xff08;\u2705 this.getUIContext() \u4e0d\u662f\u5168\u5c40\u51fd\u6570 getUIContext()&#xff0c;\u274c getUIContext() \u89e6\u53d1 Cannot find name &#039;getUIContext&#039;&#xff09;&#xff0c;UIContext \u6709 11 \u4e2a\u5b50\u7ba1\u7406\u5668&#xff08;\u2705 getFont\/getMediaQuery\/getRouter\/getPromptAction\/getComponentUtils\/getUIObserver\/getOverlayManager\/getDragController\/getMeasureUtils\/getFocusController\/getAtomicServiceBar&#xff0c;\u6bcf\u4e2a\u662f UIContext \u5b9e\u4f8b\u65b9\u6cd5\u4e0d\u662f\u5168\u5c40\u51fd\u6570&#xff0c;React promptAction \u662f\u5168\u5c40\u51fd\u6570\u9e3f\u8499 promptAction \u662f UIContext \u5b50\u7ba1\u7406\u5668&#xff09;&#xff0c;getFrameNodeById(id: string): FrameNode | null&#xff08;\u2705 \u8fd4\u56de FrameNode | null \u4e0d\u662f FrameNode&#xff0c;\u627e\u4e0d\u5230\u8fd4\u56de null \u4e0d\u662f undefined&#xff09;&#xff0c;getFilteredInspectorTree(filters?: Array&lt;string&gt;): string&#xff08;\u2705 \u8fd4\u56de string JSON \u5b57\u7b26\u4e32\u4e0d\u662f object&#xff0c;\u8981\u7528 JSON.parse \u8f6c object&#xff09;\u3002runScopedTask \u4e0d\u662f runScopedOnUiThread &#043; getUIContext \u662f\u7ec4\u4ef6\u65b9\u6cd5\u4e0d\u662f\u5168\u5c40\u51fd\u6570 &#043; 11 \u4e2a\u5b50\u7ba1\u7406\u5668\u662f\u9e3f\u8499 6.1 arkui.UIContext UI \u4e0a\u4e0b\u6587\u5751\u6838\u5fc3&#xff01;<\/p>\n<h3>\u80fd\u529b\u7cfb\u5217\u56de\u94fe<\/h3>\n<ul>\n<li>\u9e3f\u8499 7.0 \u65b0\u7279\u6027\u7bc7 1~17&#xff08;\u6c89\u6d78\u5f0f\u6bdb\u73bb\u7483\/Component3D\/\u667a\u80fd\u4f53\u6846\u67b6\/\u65b9\u821f\u5f15\u64ce\/\u661f\u76fe\u5b89\u5168\/\u661f\u6cb3\u4e92\u8054\/\u7a7a\u95f4\u97f3\u9891\/\u53ef\u53d8\u5b57\u4f53\/\u6e38\u620f\u5feb\u542f\/\u5206\u5e03\u5f0f\u6570\u636e\u76fe\/LTPO \u53ef\u53d8\u5e27\u7387\/AI \u6587\u6863\u8bc6\u522b\/\u591a\u5f62\u6001\u670d\u52a1\u7a97\u53e3\/AI \u53cd\u8bc8\/\u673a\u5bc6\u8ba1\u7b97\/\u7a7a\u95f4\u8ba1\u7b97\/\u5c0f\u827a\u5168\u9762\u8fdb\u5316&#xff09;<\/li>\n<li>\u9e3f\u8499 6.1 API 23 \u5f00\u53d1\u5751\u7cfb\u5217\u7bc7 1\u300cArkUI.modifier \u88c5\u9970\u5668\u5751\u300d\u2014\u2014attributeModifier &#043; AttributeModifier<\/li>\n<li>\u9e3f\u8499 6.1 API 23 \u5f00\u53d1\u5751\u7cfb\u5217\u7bc7 2\u300carkui.componentSnapshot \u7ec4\u4ef6\u622a\u56fe\u5751\u300d\u2014\u2014get\/getSync\/createFromBuilder \u8fd4\u56de image.PixelMap<\/li>\n<li>\u9e3f\u8499 6.1 API 23 \u5f00\u53d1\u5751\u7cfb\u5217\u7bc7 3\u300carkui.node \u8282\u70b9\u5751\u300d\u2014\u2014NodeController abstract class makeNode override &#043; BuilderNode WrappedBuilder<\/li>\n<li>\u9e3f\u8499 6.1 API 23 \u5f00\u53d1\u5751\u7cfb\u5217\u7bc7 4\u300carkui.UIContext UI \u4e0a\u4e0b\u6587\u5751\u300d\u2014\u2014runScopedTask \u4e0d\u662f runScopedOnUiThread &#043; 11 \u4e2a\u5b50\u7ba1\u7406\u5668&#xff08;\u672c\u6587&#xff09;<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u662f\u300c\u9e3f\u8499 6.1 API 23 \u5f00\u53d1\u5751\u7cfb\u5217\u300d\u7b2c 4 \u7bc7&#xff08;ArkUI \u6876\u7b2c 4 \u7bc7&#xff09;\u3002\u672c\u7bc7\u8bb2 ohos.arkui.UIContext namespace&#xff08;API 10&#xff0c;\u9e3f\u8499 6.1 API 23 \u57fa\u5ea7&#xff09;\u2014\u2014UI \u4e0a\u4e0b\u6587 UIContext class  11 \u4e2a\u5b50\u7ba1\u7406\u5668  runScopedTask  getFrameNodeById\u3002\u9e3f\u8499\u5751\u6839\u56e0&#xff1a;\u2460 runScopedTask(callb<\/p>\n","protected":false},"author":2,"featured_media":93001,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[280,292],"topic":[],"class_list":["post-93005","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-harmonyos","tag-292"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u9e3f\u84996.1 arkui.UIContext UI\u4e0a\u4e0b\u6587\u5751\uff1arunScopedTask\u4e0d\u662frunScopedOnUiThread - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/93005.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u9e3f\u84996.1 arkui.UIContext UI\u4e0a\u4e0b\u6587\u5751\uff1arunScopedTask\u4e0d\u662frunScopedOnUiThread - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u672c\u6587\u662f\u300c\u9e3f\u8499 6.1 API 23 \u5f00\u53d1\u5751\u7cfb\u5217\u300d\u7b2c 4 \u7bc7&#xff08;ArkUI \u6876\u7b2c 4 \u7bc7&#xff09;\u3002\u672c\u7bc7\u8bb2 ohos.arkui.UIContext namespace&#xff08;API 10&#xff0c;\u9e3f\u8499 6.1 API 23 \u57fa\u5ea7&#xff09;\u2014\u2014UI \u4e0a\u4e0b\u6587 UIContext class 11 \u4e2a\u5b50\u7ba1\u7406\u5668 runScopedTask getFrameNodeById\u3002\u9e3f\u8499\u5751\u6839\u56e0&#xff1a;\u2460 runScopedTask(callb\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/93005.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-11T08:49:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260811084924-6a7ae21453560.jpg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/93005.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/93005.html\",\"name\":\"\u9e3f\u84996.1 arkui.UIContext UI\u4e0a\u4e0b\u6587\u5751\uff1arunScopedTask\u4e0d\u662frunScopedOnUiThread - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-11T08:49:32+00:00\",\"dateModified\":\"2026-08-11T08:49:32+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/93005.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/93005.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/93005.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u9e3f\u84996.1 arkui.UIContext UI\u4e0a\u4e0b\u6587\u5751\uff1arunScopedTask\u4e0d\u662frunScopedOnUiThread\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u9e3f\u84996.1 arkui.UIContext UI\u4e0a\u4e0b\u6587\u5751\uff1arunScopedTask\u4e0d\u662frunScopedOnUiThread - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/93005.html","og_locale":"zh_CN","og_type":"article","og_title":"\u9e3f\u84996.1 arkui.UIContext UI\u4e0a\u4e0b\u6587\u5751\uff1arunScopedTask\u4e0d\u662frunScopedOnUiThread - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u672c\u6587\u662f\u300c\u9e3f\u8499 6.1 API 23 \u5f00\u53d1\u5751\u7cfb\u5217\u300d\u7b2c 4 \u7bc7&#xff08;ArkUI \u6876\u7b2c 4 \u7bc7&#xff09;\u3002\u672c\u7bc7\u8bb2 ohos.arkui.UIContext namespace&#xff08;API 10&#xff0c;\u9e3f\u8499 6.1 API 23 \u57fa\u5ea7&#xff09;\u2014\u2014UI \u4e0a\u4e0b\u6587 UIContext class 11 \u4e2a\u5b50\u7ba1\u7406\u5668 runScopedTask getFrameNodeById\u3002\u9e3f\u8499\u5751\u6839\u56e0&#xff1a;\u2460 runScopedTask(callb","og_url":"https:\/\/www.wsisp.com\/helps\/93005.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-11T08:49:32+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260811084924-6a7ae21453560.jpg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"8 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/93005.html","url":"https:\/\/www.wsisp.com\/helps\/93005.html","name":"\u9e3f\u84996.1 arkui.UIContext UI\u4e0a\u4e0b\u6587\u5751\uff1arunScopedTask\u4e0d\u662frunScopedOnUiThread - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-11T08:49:32+00:00","dateModified":"2026-08-11T08:49:32+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/93005.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/93005.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/93005.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u9e3f\u84996.1 arkui.UIContext UI\u4e0a\u4e0b\u6587\u5751\uff1arunScopedTask\u4e0d\u662frunScopedOnUiThread"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/93005","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=93005"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/93005\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/93001"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=93005"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=93005"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=93005"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=93005"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}