v1.0.11
#### 新增 - 新增`disabled`配置, 可以禁用多选 - 新增`create`配置, 可以创建条目, 具体见 [创建条目](https://maplemei.gitee.io/xm-select/#/example/XM27) - 方法`warning`新增参数`sustain`, 可以配置是否持续显示 - 新增全局`get`方法, 可以获取多选渲染后的对象 - 新增全局`batch`方法, 可以批量给渲染后的多选执行方法 #### Bug fixes - 修复`update`方法, 会使已选中数据丢失的问题 - 修复`Safari`浏览器下, 搜索框无法聚焦的问题
This commit is contained in:
40
src/index.js
40
src/index.js
@@ -2,15 +2,47 @@ import { name, version } from '../package.json'
|
||||
import '@/components/common/expand'
|
||||
import Core from '@/components/core'
|
||||
import '@/style/index.less'
|
||||
import '@/style/iconfont.less'
|
||||
|
||||
import '@/style/iconfont.less'
|
||||
import { selector, warn } from '@/components/common/util'
|
||||
|
||||
const object = {}
|
||||
const xmSelect = {
|
||||
name,
|
||||
version,
|
||||
render(options) {
|
||||
return new Core(options);
|
||||
}
|
||||
let instance = new Core(options);
|
||||
if(instance){
|
||||
let { el } = options;
|
||||
let select = object[el];
|
||||
select !== undefined && (delete object[el]);
|
||||
object[el] = instance;
|
||||
}
|
||||
return instance;
|
||||
},
|
||||
get(filter){
|
||||
let type = Object.prototype.toString.call(filter);
|
||||
let method;
|
||||
switch (type){
|
||||
case '[object String]':
|
||||
filter && (method = item => item === filter);
|
||||
break;
|
||||
case '[object RegExp]':
|
||||
method = item => filter.test(item);
|
||||
break;
|
||||
case '[object Function]':
|
||||
method = filter;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
let keys = Object.keys(object)
|
||||
return (method ? keys.filter(method) : keys).map(key => object[key]).filter(instance => selector(instance.options.el));
|
||||
},
|
||||
batch(filter, method){
|
||||
let args = [ ...arguments ];
|
||||
args.splice(0, 2);
|
||||
return this.get(filter).map(instance => instance[method](...args));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user