clrc-schema
v0.1.8
Published
clrc schema
Downloads
4
Readme
Schema React组件
安装
npm i clrc-schema
使用
const schema = {
//json schema
};
const data = {
//数据
};
const { Schema } = SchemaUtils;
//# 获取七牛的Uptoken,用于{ type:'string', format: 'image' }
SchemaUtils.getUptoken = function(type) {
let url = `http://yy.weixinzhuyi.com/i/get-uptoken-jsonp?type=${type}`;
return $.ajax({
dataType: 'jsonp',
url: url,
}).then(res => {
return res.data.uptokens[0];
});
};
SchemaUtils.assetsHost = '//cdn.withme.cn/';
SchemaUtils.init();
class APP extends Component {
render() {
return <div>
<Schema ref="obj" schema={schema} data={data}/>
</div>;
}
};
枚举的Schema的约束
{
type: 'enum',
title: '选项名',
enum: [
{ value: 'A', name: 'A'}, //value和name必须是这样的格式
{ value: 'B', name: 'B'},
{ value: 'C', name: 'C'},
{ value: 'D', name: 'D'},
]
}