0.0.72 • Published 9 years ago
@beisen/AutoComplete v0.0.72
AutoComplete
参数
State
isFocus: false, // 输入框样式控制
inputValue: props && props.inputDefaultValue || '' //input表单值Props
hidden: false, // 是否渲染
disabled: false, // 不可用
readOnly: true, // 只读
labelText: 'AutoComplete', //左侧 label 文字
placeholder: '请输入', // input placeholder
inputDefaultValue: null, // input 默认值
defaultItems: [], // autocomplete 数据 需传入一个DOM数组 nodeName为li
keyUpCallBack: (value, event) => console.log(value, event), // input keyup输入回调
itemCallBack: (event, data) => console.log(event), // autocomplete 点击回调 event事件回调,data为li上attribute的值
focusCallBack: (value) => console.log(value), // input keyup输入回调
blurCallBack: (event) => console.log(event), // autocomplete 点击回调
changeCallBack: (event, data) => console.log(value) // input keyup输入回调 event事件回调 data为li上attribute的值PropTypes
hidden: PropTypes.bool,
disabled: PropTypes.bool,
readOnly: PropTypes.bool,
labelText: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
]).isRequired,
placeholder: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
]),
inputDefaultValue: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
]),
defaultItems: PropTypes.arrayOf(PropTypes.element).isRequired,
keyUpCallBack: PropTypes.func.isRequired,
itemCallBack: PropTypes.func.isRequired,
focusCallBack: PropTypes.func,
blurCallBack: PropTypes.func,
changeCallBack: PropTypes.func使用方法
class App extends Component {
constructor(props) {
super(props)
this.state = {
autoValue: this.setDefaultValue()
}
}
// 返回defaultItems
setDefaultValue(count = 5) {
let items = [];
for (let i = 0; i < count; i++) {
items.push(<li key={i}>{i}</li>);
}
return items;
}
// 根据keyup返回新的defaultItems
setNewValue(count) {
this.setState({autoValue: this.setDefaultValue(count)})
}
// 清空defaultItems
restValue(event, data) {
console.log(event, data)
this.setState({autoValue: null});
}
render () {
const {autoValue} = this.state;
const options = {
labelText: 'AutoComplete',
placeholder: '请输入',
inputDefaultValue: null
}
return (
<AutoComplete {...options} defaultItems={autoValue} keyUpCallBack={::this.setNewValue} itemCallBack={::this.restValue} />
)
}
}
render(<App />, document.getElementById('content'))0.0.72
9 years ago
0.0.71
9 years ago
0.0.70
9 years ago
0.0.69
9 years ago
0.0.68
9 years ago
0.0.67
9 years ago
0.0.66
9 years ago
0.0.65
9 years ago
0.0.64
9 years ago
0.0.63
9 years ago
0.0.62
9 years ago
0.0.61
9 years ago
0.0.60
9 years ago
0.0.59
9 years ago
0.0.58
9 years ago
0.0.57
9 years ago
0.0.56
9 years ago
0.0.55
9 years ago
0.0.54
9 years ago
0.0.53
9 years ago
0.0.52
9 years ago
0.0.51
9 years ago
0.0.50
9 years ago
0.0.48
10 years ago
0.0.47
10 years ago
0.0.46
10 years ago
0.0.45
10 years ago
0.0.44
10 years ago
0.0.43
10 years ago
0.0.42
10 years ago
0.0.41
10 years ago