bee-cascader
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -181,2 +181,18 @@ 'use strict'; | ||
Cascader.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { | ||
if ('options' in nextProps) { | ||
var _options = nextProps.options; | ||
for (var i = _options.length - 1; i >= 0; i--) { | ||
_options[i]['parent'] = true; | ||
} | ||
this.setState({ | ||
option: _options, | ||
textStr: [] | ||
}); | ||
if (this.props.onClick) { | ||
this.props.onClick([]); | ||
} | ||
} | ||
}; | ||
Cascader.prototype.render = function render() { | ||
@@ -183,0 +199,0 @@ var va = this.state.textStr.join('/'); |
@@ -0,1 +1,12 @@ | ||
<a name="2.0.2"></a> | ||
## [2.0.2](https://github.com/tinper-bee/bee-cascader/compare/v2.0.1...v2.0.2) (2019-03-04) | ||
### Features | ||
* **bee-cascader:** 动态改变options ([4cdcc1f](https://github.com/tinper-bee/bee-cascader/commit/4cdcc1f)) | ||
* **bee-cascader:** 动态改变options ([ec15d2b](https://github.com/tinper-bee/bee-cascader/commit/ec15d2b)), closes [#145](https://github.com/tinper-bee/bee-cascader/issues/145) | ||
<a name="2.0.0"></a> | ||
@@ -2,0 +13,0 @@ # [2.0.0](https://github.com/tinper-bee/bee-cascader/compare/v1.0.4...v2.0.0) (2019-01-23) |
@@ -49,4 +49,9 @@ /** | ||
class Demo1 extends Component { | ||
constructor(props){ | ||
super(props); | ||
this.state={ | ||
options:options | ||
} | ||
} | ||
onClickHandler=(data)=>{ | ||
@@ -56,2 +61,42 @@ console.log("data: ",data); | ||
click=()=>{ | ||
this.setState({ | ||
options:[ | ||
{ | ||
value: '浙江1', | ||
children: [ | ||
{ | ||
value: '杭州', | ||
children: [ | ||
{ | ||
value: '西湖', | ||
children: [ | ||
{ | ||
value: '白娘子' | ||
}, | ||
{ | ||
value: '许仙' | ||
}] | ||
}] | ||
} | ||
] | ||
}, | ||
{ | ||
value: '江苏1', | ||
children: [ | ||
{ | ||
value: '南京', | ||
children: [ | ||
{ | ||
value: '中华门' | ||
}] | ||
} | ||
] | ||
}, | ||
{ | ||
value: '山东1' | ||
} | ||
] | ||
}) | ||
} | ||
render(){ | ||
@@ -61,4 +106,5 @@ return( | ||
<Col md={4}> | ||
<button onClick={this.click}>点击</button> | ||
<div className="height-150"> | ||
<Cascader options = {options} onClick={this.onClickHandler}/> | ||
<Cascader options = {this.state.options} onClick={this.onClickHandler}/> | ||
</div> | ||
@@ -65,0 +111,0 @@ </Col> |
@@ -13,3 +13,3 @@ import {Col, Row} from 'bee-layout'; | ||
var Demo1 = require("./demolist/Demo1");var DemoArray = [{"example":<Demo1 />,"title":" 基础级联菜单","code":"/**\n *\n * @title 基础级联菜单\n * @description\n *\n */\n\nimport React, { Component } from 'react';\nimport { Cascader, Row, Col } from 'tinper-bee';\n\n const options = [\n \t{\n \t value: '浙江',\n \t children: [\n \t\t {\n \t\t value: '杭州',\n \t\t children: [\n \t\t\t {\n \t\t\t value: '西湖',\n \t\t\t children: [\n \t\t\t\t {\n \t\t\t\t value: '白娘子'\n \t\t\t\t },\n \t\t\t\t {\n \t\t\t\t value: '许仙'\n \t\t\t\t }]\n \t\t\t }]\n \t\t }\n \t ]\n \t},\n \t{\n \t value: '江苏',\n \t children: [\n \t\t {\n \t\t value: '南京',\n \t\t children: [\n \t\t\t {\n \t\t\t value: '中华门'\n \t\t\t }]\n \t\t }\n \t ]\n \t},\n \t{\n \t value: '山东'\n \t}\n ];\n class Demo1 extends Component {\n\n\n\tonClickHandler=(data)=>{\n\t\tconsole.log(\"data: \",data);\n\t}\n\n \trender(){\n \t\treturn(\n <Row>\n <Col md={4}>\n <div className=\"height-150\">\n \t<Cascader options = {options} onClick={this.onClickHandler}/>\n </div>\n </Col>\n </Row>\n \t\t)\n \t}\n }\n","desc":""}] | ||
var Demo1 = require("./demolist/Demo1");var DemoArray = [{"example":<Demo1 />,"title":" 基础级联菜单","code":"/**\n *\n * @title 基础级联菜单\n * @description\n *\n */\n\nimport React, { Component } from 'react';\nimport { Cascader, Row, Col } from 'tinper-bee';\n\n const options = [\n \t{\n \t value: '浙江',\n \t children: [\n \t\t {\n \t\t value: '杭州',\n \t\t children: [\n \t\t\t {\n \t\t\t value: '西湖',\n \t\t\t children: [\n \t\t\t\t {\n \t\t\t\t value: '白娘子'\n \t\t\t\t },\n \t\t\t\t {\n \t\t\t\t value: '许仙'\n \t\t\t\t }]\n \t\t\t }]\n \t\t }\n \t ]\n \t},\n \t{\n \t value: '江苏',\n \t children: [\n \t\t {\n \t\t value: '南京',\n \t\t children: [\n \t\t\t {\n \t\t\t value: '中华门'\n \t\t\t }]\n \t\t }\n \t ]\n \t},\n \t{\n \t value: '山东'\n \t}\n ];\n class Demo1 extends Component {\n\tconstructor(props){\n\t\tsuper(props);\n\t\tthis.state={\n\t\t\toptions:options\n\t\t}\n\t}\n\n\tonClickHandler=(data)=>{\n\t\tconsole.log(\"data: \",data);\n\t}\n\n\tclick=()=>{\n\t\tthis.setState({\n\t\t\toptions:[\n\t\t\t\t{\n\t\t\t\t\tvalue: '浙江1',\n\t\t\t\t\tchildren: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvalue: '杭州',\n\t\t\t\t\t\t\tchildren: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tvalue: '西湖',\n\t\t\t\t\t\t\t\t\tchildren: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tvalue: '白娘子'\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tvalue: '许仙'\n\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tvalue: '江苏1',\n\t\t\t\t\tchildren: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvalue: '南京',\n\t\t\t\t\t\t\tchildren: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tvalue: '中华门'\n\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tvalue: '山东1'\n\t\t\t\t}\n\t\t\t]\n\t\t})\n\t}\n \trender(){\n \t\treturn(\n <Row>\n <Col md={4}>\n\t\t\t\t\t\t\t\t\t<button onClick={this.click}>点击</button>\n <div className=\"height-150\">\n \t<Cascader options = {this.state.options} onClick={this.onClickHandler}/>\n </div>\n </Col>\n </Row>\n \t\t)\n \t}\n }\n","desc":""}] | ||
@@ -16,0 +16,0 @@ |
{ | ||
"name": "bee-cascader", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Cascader ui component for react", | ||
@@ -16,3 +16,3 @@ "keywords": [ | ||
}, | ||
"homepage": "https://github.com/tinper-beebee-cascader.git", | ||
"homepage": "https://github.com/tinper-bee/bee-cascader.git", | ||
"author": "supernever", | ||
@@ -19,0 +19,0 @@ "repository": "http://github.com/tinper-bee/bee-cascader", |
@@ -130,2 +130,17 @@ import React, { Component } from 'react'; | ||
} | ||
componentWillReceiveProps(nextProps){ | ||
if('options' in nextProps){ | ||
let options = nextProps.options; | ||
for (let i = options.length - 1; i >= 0; i--) { | ||
options[i]['parent'] = true | ||
} | ||
this.setState({ | ||
option:options, | ||
textStr:[] | ||
}) | ||
if(this.props.onClick){ | ||
this.props.onClick([]); | ||
} | ||
} | ||
} | ||
render(){ | ||
@@ -132,0 +147,0 @@ let va = this.state.textStr.join('/'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
1184572
12371
0
21
2
1