Skip to content
Permalink
Browse files

fix(bee-radio): radiogroup 下只有一个radio的时候报错

  • Loading branch information...
liushaozhen committed May 24, 2019
1 parent 4391467 commit 13dd41917da7ea21fb30e529f5f47cd56849dc4f
Showing with 112 additions and 77 deletions.
  1. +1 −1 build/RadioGroup.js
  2. +1 −1 demo/index.js
  3. +1 −1 dist/demo.css.map
  4. +106 −71 dist/demo.js
  5. +1 −1 dist/demo.js.map
  6. +1 −1 package.json
  7. +1 −1 src/RadioGroup.js
@@ -82,7 +82,7 @@ var RadioGroup = function (_React$Component) {
array.push(item.props.value);
});
} else {
array.push(children.props.value);
array.push(children[0].props.value);
}
return array;
};
@@ -8,7 +8,7 @@ import Button from '../src';



var Demo1 = require("./demolist/Demo1");var Demo2 = require("./demolist/Demo2");var Demo3 = require("./demolist/Demo3");var Demo4 = require("./demolist/Demo4");var Demo5 = require("./demolist/Demo5");var DemoArray = [{"example":<Demo1 />,"title":" Radio 基本用法","code":"/**\r\n * @title Radio 基本用法\r\n * @description `selectedValue`参数被选中的radio值,`disabled`参数设置是否可用,`onChange`设置值改变的回调\r\n */\r\n\r\nimport React, { Component } from 'react'\r\nimport { Radio } from 'tinper-bee';\r\n\r\n\r\n\r\nclass Demo1 extends Component{\r\n constructor(props) {\r\n \tsuper(props);\r\n \tthis.state = {\r\n \tselectedValue: '2'\r\n };\r\n }\r\n handleChange(value) {\r\n this.setState({selectedValue: value});\r\n }\r\n render() {\r\n return (\r\n <Radio.RadioGroup\r\n name=\"fruits\"\r\n selectedValue={this.state.selectedValue}\r\n onChange={this.handleChange.bind(this)}>\r\n <Radio value=\"1\" disabled>苹果</Radio>\r\n <Radio value=\"2\" disabled>香蕉</Radio>\r\n <Radio value=\"3\" >葡萄</Radio>\r\n <Radio value=\"4\" >菠萝</Radio>\r\n <Radio value=\"5\" >梨</Radio>\r\n <Radio value=\"6\" >石榴</Radio>\r\n </Radio.RadioGroup> \r\n )\r\n }\r\n};\r\n\r\n","desc":" `selectedValue`参数被选中的radio值,`disabled`参数设置是否可用,`onChange`设置值改变的回调"},{"example":<Demo2 />,"title":" 不同颜色的radio","code":"/**\r\n * @title 不同颜色的radio\r\n * @description `colors`参数控制背景色\r\n */\r\n\r\nimport React, { Component } from 'react'\r\nimport { Radio } from 'tinper-bee';\r\n\r\n\r\n\r\nclass Demo2 extends Component{\r\n constructor(props) {\r\n \tsuper(props);\r\n \tthis.state = {\r\n \tselectedValue: '3'\r\n };\r\n }\r\n handleChange(value) {\r\n this.setState({selectedValue: value});\r\n }\r\n render() {\r\n return (\r\n <Radio.RadioGroup\r\n name=\"color\"\r\n selectedValue={this.state.selectedValue}\r\n onChange={this.handleChange.bind(this)}>\r\n <Radio colors=\"primary\" value=\"1\" >苹果</Radio>\r\n <Radio colors=\"success\" value=\"2\" >香蕉</Radio>\r\n <Radio colors=\"info\" value=\"3\" >葡萄</Radio>\r\n <Radio colors=\"warning\" value=\"4\" >菠萝</Radio>\r\n <Radio colors=\"danger\" value=\"5\" >梨</Radio>\r\n <Radio colors=\"dark\" value=\"6\" >石榴</Radio>\r\n </Radio.RadioGroup>\r\n )\r\n }\r\n};\r\n\r\n","desc":" `colors`参数控制背景色"},{"example":<Demo3 />,"title":" 竖方向Radio","code":"/**\r\n * @title 竖方向Radio\r\n * @description 可以通过style来设置radio样式\r\n */\r\n\r\nimport React, { Component } from 'react'\r\nimport { Radio } from 'tinper-bee';\r\n\r\n\r\n\r\nclass Demo3 extends Component{\r\n constructor(props) {\r\n \tsuper(props);\r\n \tthis.state = {\r\n \tselectedValue: '1'\r\n };\r\n }\r\n handleChange(value) {\r\n this.setState({selectedValue: value});\r\n }\r\n render() {\r\n const radioStyle = {\r\n display: 'block'\r\n };\r\n return (\r\n <div className=\"demo3\">\r\n <Radio.RadioGroup\r\n name=\"team\"\r\n selectedValue={this.state.selectedValue}\r\n onChange={this.handleChange.bind(this)}>\r\n <Radio style={radioStyle} value=\"1\" >苹果</Radio>\r\n <Radio style={radioStyle} value=\"2\" >香蕉</Radio>\r\n <Radio style={radioStyle} value=\"3\" >葡萄</Radio>\r\n <Radio style={radioStyle} value=\"4\" >菠萝</Radio>\r\n <Radio style={radioStyle} value=\"5\" >梨</Radio>\r\n <Radio style={radioStyle} value=\"6\" >石榴</Radio>\r\n </Radio.RadioGroup>\r\n </div>\r\n )\r\n }\r\n};\r\n\r\n","desc":" 可以通过style来设置radio样式","scss_code":".demo3 .u-radio-group .u-radio{\r\n margin-bottom: 8px;\r\n}"},{"example":<Demo4 />,"title":" RadioButton 基本使用","code":"/**\r\n * @title RadioButton 基本使用\r\n * @description `selectedValue`参数设置被选中的radio值,`onChange`设置值改变的回调\r\n */\r\n\r\nimport React, { Component } from 'react'\r\nimport { Radio } from 'tinper-bee';\r\n\r\nconst RadioGroup = Radio.RadioGroup;\r\n\r\nclass Demo4 extends Component{\r\n constructor(props) {\r\n \tsuper(props);\r\n \tthis.state = {\r\n selectedValue: 'orange',\r\n selectedValue2: 'apple'\r\n };\r\n }\r\n handleChange(value) {\r\n this.setState({selectedValue: value});\r\n }\r\n handleChange2(value) {\r\n this.setState({selectedValue2: value});\r\n }\r\n render() {\r\n return (\r\n <div>\r\n <Radio.RadioGroup\r\n name=\"fruit\"\r\n selectedValue={this.state.selectedValue}\r\n onChange={this.handleChange.bind(this)}>\r\n <Radio.RadioButton value=\"apple\">apple</Radio.RadioButton>\r\n <Radio.RadioButton value=\"banana\">banana</Radio.RadioButton>\r\n <Radio.RadioButton value=\"orange\">orange</Radio.RadioButton>\r\n </Radio.RadioGroup>\r\n\r\n <div style={{ marginTop: 16 }}>\r\n <Radio.RadioGroup \r\n selectedValue={this.state.selectedValue2}\r\n onChange={this.handleChange2.bind(this)}>\r\n <Radio.RadioButton value=\"apple\">apple</Radio.RadioButton>\r\n <Radio.RadioButton value=\"banana\" disabled>banana</Radio.RadioButton>\r\n <Radio.RadioButton value=\"orange\">orange</Radio.RadioButton>\r\n </Radio.RadioGroup>\r\n </div>\r\n\r\n <div style={{ marginTop: 16 }}>\r\n <Radio.RadioGroup selectedValue=\"apple\">\r\n <Radio.RadioButton value=\"apple\" disabled>apple</Radio.RadioButton>\r\n <Radio.RadioButton value=\"banana\" disabled>banana</Radio.RadioButton>\r\n <Radio.RadioButton value=\"orange\" disabled>orange</Radio.RadioButton>\r\n </Radio.RadioGroup>\r\n </div>\r\n </div>\r\n\r\n )\r\n }\r\n};\r\n\r\n","desc":" `selectedValue`参数设置被选中的radio值,`onChange`设置值改变的回调"},{"example":<Demo5 />,"title":" 红色填充的 Radio","code":"/**\r\n * @title 红色填充的 Radio\r\n * @description `inverse` 参数设置选中为红色填充。\r\n */\r\n\r\nimport React, { Component } from 'react'\r\nimport { Radio } from 'tinper-bee';\r\n\r\n\r\n\r\nclass Demo1 extends Component{\r\n constructor(props) {\r\n \tsuper(props);\r\n \tthis.state = {\r\n \tselectedValue: '1'\r\n };\r\n }\r\n handleChange(value) {\r\n this.setState({selectedValue: value});\r\n }\r\n render() {\r\n return (\r\n <Radio.RadioGroup\r\n name=\"fruits\"\r\n selectedValue={this.state.selectedValue}\r\n onChange={this.handleChange.bind(this)}>\r\n <Radio value=\"1\" inverse>苹果</Radio>\r\n <Radio value=\"2\" inverse>香蕉</Radio>\r\n <Radio value=\"3\" inverse>葡萄</Radio>\r\n </Radio.RadioGroup> \r\n )\r\n }\r\n};\r\n\r\n","desc":" `inverse` 参数设置选中为红色填充。"}]
var Demo1 = require("./demolist/Demo1");var Demo2 = require("./demolist/Demo2");var Demo3 = require("./demolist/Demo3");var Demo4 = require("./demolist/Demo4");var Demo5 = require("./demolist/Demo5");var DemoArray = [{"example":<Demo1 />,"title":" Radio 基本用法","code":"/**\n * @title Radio 基本用法\n * @description `selectedValue`参数被选中的radio值,`disabled`参数设置是否可用,`onChange`设置值改变的回调\n */\n\nimport React, { Component } from 'react'\nimport { } from 'tinper-bee';\nimport Radio from \"tinper-bee/lib/src\";\n\n\n\nclass Demo1 extends Component{\n constructor(props) {\n \tsuper(props);\n \tthis.state = {\n \tselectedValue: '2'\n };\n }\n handleChange(value) {\n this.setState({selectedValue: value});\n }\n render() {\n return (\n <Radio.RadioGroup\n name=\"fruits\"\n selectedValue={this.state.selectedValue}\n onChange={this.handleChange.bind(this)}>\n <Radio value=\"1\" disabled>苹果</Radio>\n <Radio value=\"2\" disabled>香蕉</Radio>\n <Radio value=\"3\" >葡萄</Radio>\n <Radio value=\"4\" >菠萝</Radio>\n <Radio value=\"5\" >梨</Radio>\n <Radio value=\"6\" >石榴</Radio>\n </Radio.RadioGroup> \n )\n }\n};\n\n","desc":" `selectedValue`参数被选中的radio值,`disabled`参数设置是否可用,`onChange`设置值改变的回调"},{"example":<Demo2 />,"title":" 不同颜色的radio","code":"/**\n * @title 不同颜色的radio\n * @description `colors`参数控制背景色\n */\n\nimport React, { Component } from 'react'\nimport { } from 'tinper-bee';\nimport Radio from \"tinper-bee/lib/src\";\n\n\n\nclass Demo2 extends Component{\n constructor(props) {\n \tsuper(props);\n \tthis.state = {\n \tselectedValue: '3'\n };\n }\n handleChange(value) {\n this.setState({selectedValue: value});\n }\n render() {\n return (\n <Radio.RadioGroup\n name=\"color\"\n selectedValue={this.state.selectedValue}\n onChange={this.handleChange.bind(this)}>\n <Radio colors=\"primary\" value=\"1\" >苹果</Radio>\n <Radio colors=\"success\" value=\"2\" >香蕉</Radio>\n <Radio colors=\"info\" value=\"3\" >葡萄</Radio>\n <Radio colors=\"warning\" value=\"4\" >菠萝</Radio>\n <Radio colors=\"danger\" value=\"5\" >梨</Radio>\n <Radio colors=\"dark\" value=\"6\" >石榴</Radio>\n </Radio.RadioGroup>\n )\n }\n};\n\n","desc":" `colors`参数控制背景色"},{"example":<Demo3 />,"title":" 竖方向Radio","code":"/**\n * @title 竖方向Radio\n * @description 可以通过style来设置radio样式\n */\n\nimport React, { Component } from 'react'\nimport { } from 'tinper-bee';\nimport Radio from \"tinper-bee/lib/src\";\n\n\n\nclass Demo3 extends Component{\n constructor(props) {\n \tsuper(props);\n \tthis.state = {\n \tselectedValue: '1'\n };\n }\n handleChange(value) {\n this.setState({selectedValue: value});\n }\n render() {\n const radioStyle = {\n display: 'block'\n };\n return (\n <div className=\"demo3\">\n <Radio.RadioGroup\n name=\"team\"\n selectedValue={this.state.selectedValue}\n onChange={this.handleChange.bind(this)}>\n <Radio style={radioStyle} value=\"1\" >苹果</Radio>\n <Radio style={radioStyle} value=\"2\" >香蕉</Radio>\n <Radio style={radioStyle} value=\"3\" >葡萄</Radio>\n <Radio style={radioStyle} value=\"4\" >菠萝</Radio>\n <Radio style={radioStyle} value=\"5\" >梨</Radio>\n <Radio style={radioStyle} value=\"6\" >石榴</Radio>\n </Radio.RadioGroup>\n </div>\n )\n }\n};\n\n","desc":" 可以通过style来设置radio样式","scss_code":".demo3 .u-radio-group .u-radio{\n margin-bottom: 8px;\n}"},{"example":<Demo4 />,"title":" RadioButton 基本使用","code":"/**\n * @title RadioButton 基本使用\n * @description `selectedValue`参数设置被选中的radio值,`onChange`设置值改变的回调\n */\n\nimport React, { Component } from 'react'\nimport { } from 'tinper-bee';\nimport Radio from \"tinper-bee/lib/src\";\n\nconst RadioGroup = Radio.RadioGroup;\n\nclass Demo4 extends Component{\n constructor(props) {\n \tsuper(props);\n \tthis.state = {\n selectedValue: 'orange',\n selectedValue2: 'apple'\n };\n }\n handleChange(value) {\n this.setState({selectedValue: value});\n }\n handleChange2(value) {\n this.setState({selectedValue2: value});\n }\n render() {\n return (\n <div>\n <Radio.RadioGroup\n name=\"fruit\"\n selectedValue={this.state.selectedValue}\n onChange={this.handleChange.bind(this)}>\n <Radio.RadioButton value=\"apple\">apple</Radio.RadioButton>\n <Radio.RadioButton value=\"banana\">banana</Radio.RadioButton>\n <Radio.RadioButton value=\"orange\">orange</Radio.RadioButton>\n </Radio.RadioGroup>\n\n <div style={{ marginTop: 16 }}>\n <Radio.RadioGroup \n selectedValue={this.state.selectedValue2}\n onChange={this.handleChange2.bind(this)}>\n <Radio.RadioButton value=\"apple\">apple</Radio.RadioButton>\n <Radio.RadioButton value=\"banana\" disabled>banana</Radio.RadioButton>\n <Radio.RadioButton value=\"orange\">orange</Radio.RadioButton>\n </Radio.RadioGroup>\n </div>\n\n <div style={{ marginTop: 16 }}>\n <Radio.RadioGroup selectedValue=\"apple\">\n <Radio.RadioButton value=\"apple\" disabled>apple</Radio.RadioButton>\n <Radio.RadioButton value=\"banana\" disabled>banana</Radio.RadioButton>\n <Radio.RadioButton value=\"orange\" disabled>orange</Radio.RadioButton>\n </Radio.RadioGroup>\n </div>\n </div>\n\n )\n }\n};\n\n","desc":" `selectedValue`参数设置被选中的radio值,`onChange`设置值改变的回调"},{"example":<Demo5 />,"title":" 红色填充的 Radio","code":"/**\n * @title 红色填充的 Radio\n * @description `inverse` 参数设置选中为红色填充。\n */\n\nimport React, { Component } from 'react'\nimport { } from 'tinper-bee';\nimport Radio from \"tinper-bee/lib/src\";\n\n\n\nclass Demo1 extends Component{\n constructor(props) {\n \tsuper(props);\n \tthis.state = {\n \tselectedValue: '1'\n };\n }\n handleChange(value) {\n this.setState({selectedValue: value});\n }\n render() {\n return (\n <Radio.RadioGroup\n name=\"fruits\"\n selectedValue={this.state.selectedValue}\n onChange={this.handleChange.bind(this)}>\n <Radio value=\"1\" inverse>苹果</Radio>\n <Radio value=\"2\" inverse>香蕉</Radio>\n <Radio value=\"3\" inverse>葡萄</Radio>\n </Radio.RadioGroup> \n )\n }\n};\n\n","desc":" `inverse` 参数设置选中为红色填充。"}]


class Demo extends Component {

Large diffs are not rendered by default.

0 comments on commit 13dd419

Please sign in to comment.
You can’t perform that action at this time.