v1.1.4
This commit is contained in:
@@ -394,12 +394,48 @@ class Framework extends Component{
|
||||
componentDidMount(){
|
||||
this.prepare = true;
|
||||
|
||||
//监听键盘事件
|
||||
this.base.addEventListener('keydown', e => {
|
||||
let keyCode = e.keyCode;
|
||||
if(keyCode === 13){
|
||||
this.onClick()
|
||||
}
|
||||
});
|
||||
|
||||
//表单验证
|
||||
this.input = this.base.querySelector('.xm-select-default');
|
||||
//监听class的变化, 然后进行边框变色处理, 或者更多的处理
|
||||
let MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
|
||||
MutationObserver && new MutationObserver(mutations => {
|
||||
mutations.forEach(mutation => {
|
||||
if (mutation.type == "attributes") {
|
||||
let attr = mutation.attributeName;
|
||||
if(attr === 'class'){
|
||||
if(this.input.className.indexOf('layui-form-danger') !== -1){
|
||||
this.input.className = 'xm-select-default';
|
||||
this.base.style.borderColor = this.props.theme.maxColor;
|
||||
//这里可以自己新增一个回调, 也许看到源码的你能够看到
|
||||
// this.base.scrollIntoView({ behavior: "smooth" });
|
||||
}
|
||||
}
|
||||
console.log(attr);
|
||||
}
|
||||
});
|
||||
}).observe(this.input, { attributes: true });
|
||||
|
||||
//监听form的重置按钮
|
||||
let dom = this.base;
|
||||
while(dom){
|
||||
dom = dom.parentElement;
|
||||
if(dom.tagName === 'FORM'){
|
||||
let resetBtn = dom.querySelector('button[type="reset"]')
|
||||
resetBtn && resetBtn.addEventListener('click', e => {
|
||||
this.init(this.props, true);
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//此时页面又被重新渲染了
|
||||
|
||||
@@ -355,7 +355,7 @@ class General extends Component{
|
||||
info = { icon: 'xm-iconfont xm-icon-quanxuan', name, method: (pageData) => {
|
||||
const { optgroup, disabled } = prop;
|
||||
const list = pageData.filter(item => !item[optgroup]).filter(item => !item[disabled])
|
||||
this.props.onReset(mergeArr(list, sels, prop), 'sels');
|
||||
this.props.onReset(radio ? list.slice(0, 1) : mergeArr(list, sels, prop), 'sels');
|
||||
} };
|
||||
}else if(tool === 'CLEAR'){
|
||||
info = { icon: 'xm-iconfont xm-icon-qingkong', name, method: (pageData) => {
|
||||
@@ -375,7 +375,7 @@ class General extends Component{
|
||||
list.splice(index, 1);
|
||||
}
|
||||
})
|
||||
this.props.onReset(mergeArr(list, selectedList, prop), 'sels');
|
||||
this.props.onReset(radio ? selectedList.slice(0, 1) : mergeArr(list, selectedList, prop), 'sels');
|
||||
} };
|
||||
}else {
|
||||
info = tool
|
||||
@@ -407,7 +407,7 @@ class General extends Component{
|
||||
borderColor: theme.color,
|
||||
};
|
||||
const itemStyle = {}
|
||||
|
||||
|
||||
//处理键盘的选择背景色
|
||||
if(item[value] === this.state.val){
|
||||
itemStyle.backgroundColor = theme.hover
|
||||
|
||||
Reference in New Issue
Block a user