(window.webpackJsonp=window.webpackJsonp||[]).push([[204],{548:function(t,e,s){"use strict";s.r(e);var a=s(15),n=Object(a.a)({},(function(){var t=this,e=t._self._c;return e("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[e("h1",{attrs:{id:"动态显示-隐藏组件"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#动态显示-隐藏组件"}},[t._v("#")]),t._v(" 动态显示/隐藏组件")]),t._v(" "),e("h2",{attrs:{id:"如何动态显示-隐藏组件"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#如何动态显示-隐藏组件"}},[t._v("#")]),t._v(" 如何动态显示/隐藏组件")]),t._v(" "),e("p",[t._v("从 8.5.2 版本开始，Foxit PDF SDK for Web 提供了 3 个新的接口 (keepState, revokeKeepState, isStateKept)，以帮助用户动态显示/隐藏组件。keepState 是专门提供给应用层用于管理组件状态的方法，Web SDK 内部不会使用。当前，其仅对 show/hide 状态有效。用户可以先调用 show/hide 接口来控制组件的可见性，然后调用 keepState 接口来保持当前的可见性状态。使用 keepState 的目的是防止 SDK 内部在用户不确定的时机执行修改状态，从而让用户无法控制组件状态。")]),t._v(" "),e("p",[t._v("示例:")]),t._v(" "),e("div",{staticClass:"language-js extra-class"},[e("pre",{pre:!0,attrs:{class:"language-js"}},[e("code",[e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("const")]),t._v(" redactApplyMenu "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("await")]),t._v(" pdfui"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("getComponentByName")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token string"}},[t._v("'fv--contextmenu-item-apply'")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n\nredactApplyMenu"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("hide")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// First hide component.")]),t._v("\nredactApplyMenu"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("keepState")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// Keep the current hide state of the component, which prevents the component from being showed inside the SDK.")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// Revoke the keep-state when necessary.")]),t._v("\nredactApplyMenu"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("revokeKeepState")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n")])])])])}),[],!1,null,null,null);e.default=n.exports}}]);