0.1.8 • Published 8 years ago

clrc-schema v0.1.8

Weekly downloads
-
License
MIT
Repository
-
Last release
8 years ago

Schema React组件 NPM version NPM downloads MIT License

安装

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'},
  ]
}
0.1.8

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago