OneScript

Form

在可滚动表单中分组展示设置与控件。

Form 以系统设置的风格排列 Toggle、Picker、Slider、Stepper 等控件。子视图中的 Section 会成为一个分组。

import { Form, Section, Toggle, useState } from "onescript/views"

function Settings() {
  const [notifications, setNotifications] = useState(true)
  return (
    <Form>
      <Section
        header="通用"
        footer="对所有设备生效。"
      >
        <Toggle
          isOn={notifications}
          onChange={setNotifications}
        >
          通知
        </Toggle>
      </Section>
    </Form>
  )
}

Form 自带滚动,不要放进 ScrollView。使用 formStyle 调整外观。也支持修饰符。仅在 App 和 Action 视图会话中可用;在 Widget 中使用会报「不支持的视图类型」错误。

How is this guide?

最后更新于