UNPKG

1.18 kBTypeScriptView Raw
1import { ComponentType } from 'react'
2import { StandardProps } from './common'
3interface RootPortalProps extends StandardProps {
4 /**
5 * 是否从页面中脱离出来
6 * @supported weapp, alipay
7 * @default true
8 */
9 enable?: boolean
10}
11/** root-portal
12 * 使整个子树从页面中脱离出来,类似于在 CSS 中使用 fixed position 的效果。主要用于制作弹窗、弹出层等。
13 * @see https://developers.weixin.qq.com/miniprogram/dev/component/root-portal.html
14 * @classification viewContainer
15 * @supported weapp
16 * @example_react
17 * ```tsx
18 * import { useState } from 'react'
19 * import { RootPortal, View, Button } from '@tarojs/components'
20 *
21 * export default function RootPortalExample {
22 * const [show, setShow] = useState(false)
23 * const toggle = () => {
24 * setShow(!show)
25 * }
26 * render () {
27 * return (
28 * <View>
29 * <Button onClick={toggle}>显示root-portal</Button>
30 * {
31 * show && (<RootPortal><View>content</View></RootPortal>)
32 * }
33 * </View>
34 * )
35 * }
36 * }
37 * ```
38 */
39declare const RootPortal: ComponentType<RootPortalProps>
40export { RootPortal, RootPortalProps }