docs: i18n/dataSource demo for React Renderer

Link: https://code.aone.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/codereview/3642343

* docs: add dataSource demo

* docs: i18n demo
This commit is contained in:
wuji.xwt 2020-09-03 10:20:35 +08:00
parent ac543a1c3b
commit d4ab19a671
6 changed files with 178 additions and 15 deletions

View File

@ -1,9 +1,8 @@
import { Message, Dialog } from '@alifd/next';
import { Message } from '@alifd/next';
import moment from 'moment';
export default {
Message,
Dialog,
moment,
test: function(msg) {
this.Message.notice(msg);

View File

@ -0,0 +1,37 @@
---
title: 数据源使用
order: 4
---
````jsx
import React, { PureComponent } from 'react';
import ReactDOM from 'react-dom';
import ReactRenderer from '@ali/lowcode-react-renderer';
import schema from './schemas/dataSource';
import components from './config/components/index';
import utils from './config/utils';
import constants from './config/constants';
class Demo extends PureComponent {
static displayName = 'renderer-demo';
render() {
return (
<div className="demo">
<ReactRenderer
key={schema.fileName}
schema={schema}
components={components}
appHelper={{
utils,
constants
}}
/>
</div>
);
}
}
ReactDOM.render((
<Demo />
), mountNode);
````

View File

@ -0,0 +1,42 @@
---
title: 国际化
order: 5
---
````jsx
import React, { PureComponent } from 'react';
import ReactDOM from 'react-dom';
import ReactRenderer from '@ali/lowcode-react-renderer';
import schema from './schemas/i18n';
import components from './config/components/index';
import utils from './config/utils';
import constants from './config/constants';
class Demo extends PureComponent {
static displayName = 'renderer-demo';
render() {
return (
<div className="demo">
<ReactRenderer
key={schema.fileName}
schema={schema}
components={components}
appHelper={{
utils,
constants
}}
locale="zh-CN"
messages={{
"hello": "你好",
"china": "中国"
}}
/>
</div>
);
}
}
ReactDOM.render((
<Demo />
), mountNode);
````

View File

@ -7,8 +7,33 @@ export default {
children: [
{
"componentName": "Dropdown",
"props": { "trigger": [{ "componentName": "Button", "props": { "type": "primary" }, "children": "确定" }], "triggerType": "click"},
"children": [{ "componentName": "Menu", "props": { "style": { "width": 200 } }, "children": [{ "componentName": "MenuItem", "props": {}, "children": "Option 1" }, { "componentName": "MenuItem", "props": { "disabled": false }, "children": "option 2" }, { "componentName": "MenuItem", "props": { "disabled": false }, "children": "option 3" }]}]
"props": {
"trigger": [
{
"componentName": "Button",
"props": {
"type": "primary"
},
"children": "确定"
}
],
"triggerType": "click"
},
"children": [
{
"componentName": "Menu",
"props": {
"style": {
"width": 200
}
},
"children": [
{ "componentName": "MenuItem", "props": {}, "children": "Option 1" },
{ "componentName": "MenuItem", "props": { "disabled": false }, "children": "option 2" },
{ "componentName": "MenuItem", "props": { "disabled": false }, "children": "option 3" }
]
}
]
},
{
"componentName": "Menu",
@ -17,17 +42,20 @@ export default {
"width": 200
}
},
"children": [{
"componentName": "MenuItem",
"props": {
},
"children": "Option 1"
}, {
"componentName": "MenuItem",
"props": {
},
"children": "Option 2"
}]
"children": [
{
"componentName": "MenuItem",
"props": {
},
"children": "Option 1"
},
{
"componentName": "MenuItem",
"props": {
},
"children": "Option 2"
}
]
}
]
};

View File

@ -0,0 +1,37 @@
export default {
"componentName": "Page",
"fileName": "dataSource",
"props": {},
"children": [{
"componentName": "Div",
"props": {},
"children": [{
"componentName": "Text",
"props": {
"text": "{{this.item.title}}"
}
}, {
"componentName": "Switch",
"props": {
"checkedChildren": "开",
"unCheckedChildren": "关",
"checked": "{{this.item.done}}"
}
}],
"loop": "{{this.dataSourceMap.todos.data}}"
}],
"dataSource": {
"list": [{
"id": "todos",
"isInit": true,
"type": "jsonp",
"options": {
"method": "GET",
"uri": "https://mocks.alibaba-inc.com/mock/D8iUX7zB/todo_getAll"
},
"dataHandler": function dataHandler(data) {
return data.data;
}
}]
}
}

View File

@ -0,0 +1,20 @@
export default {
"componentName": "Page",
"fileName": "i18n",
"props": {},
"children": [{
"componentName": "Div",
"props": {},
"children": [{
"componentName": "Text",
"props": {
"text": "{{this.i18n('hello')}}"
}
}, {
"componentName": "Text",
"props": {
"text": "{{this.i18n('china')}}"
}
}]
}]
}