FieldPicker
一个字段选择器组件,可以选择对应 视图ID 里面的字段
参数
Name | Type |
---|---|
props | IFieldPicker |
返回值
Element
示例
普通示例
import React, { useState } from 'react';
import { FieldPicker, useActiveViewId } from '@apitable/widget-sdk';
const Example = () => {
const viewId = useActiveViewId();
const [fieldId, setFieldId] = useState()
return <FieldPicker viewId={viewId} fieldId={fieldId} onChange={option => setFieldId(option.value)} />
}
配合 useCloudStorage 实现持久化存储
import React, { useState } from 'react';
import { FieldPicker, useActiveViewId, useCloudStorage } from '@apitable/widget-sdk';
const ExampleCloud = () => {
const viewId = useActiveViewId();
const [fieldId, setFieldId] = useCloudStorage('selectFieldId');
return <FieldPicker viewId={viewId} fieldId={fieldId} onChange={option => setFieldId(option.value)} />;
};