OneScript

fullScreenCover

覆盖整个屏幕的弹出页面。

fullScreenCover(options) 的参数与 sheet 相同,但内容覆盖整个屏幕,用户无法下滑关闭,需要在内容中提供关闭按钮。

import { Button, Modifier, Text, useState, VStack } from "onescript/views"

function Onboarding() {
  const [shown, setShown] = useState(true)

  return (
    <Text modifier={Modifier.fullScreenCover({
      isPresented: shown,
      onDismiss: () => setShown(false),
      content: (
        <VStack spacing={16}>
          <Text>欢迎使用</Text>
          <Button action={() => setShown(false)}>开始</Button>
        </VStack>
      ),
    })}>
      首页
    </Text>
  )
}
参数类型说明
isPresentedboolean是否显示。
onDismiss() => void系统关闭时调用,需在其中把 isPresented 设为 false。
contentViewChild弹出的内容。

How is this guide?

最后更新于