bug修复
This commit is contained in:
maplemei 2019-11-07 10:52:51 +08:00
parent b3026c7dce
commit 53521d7854
14 changed files with 53 additions and 21 deletions

View File

@ -1,5 +1,20 @@
## 更新日志
### 1.0.13
*2019-11-07*
#### 新增
- `get`方法新增`single`参数, 可以获取单实例
#### Bug fixes
- 修复`reset`方法报错
- 修复IE下工具条全选数据错误
- 修改文档简单兼容IE
### 1.0.12
*2019-10-24*

2
dist/static/2.js vendored

File diff suppressed because one or more lines are too long

2
dist/static/3.js vendored

File diff suppressed because one or more lines are too long

10
dist/static/docs.js vendored

File diff suppressed because one or more lines are too long

2
dist/xm-select.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,4 @@
import "babel-polyfill"
import Vue from 'vue';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
@ -15,7 +16,6 @@ Vue.component('demo-block', demoBlock);
import './assets/common.less'
const router = new VueRouter({
mode: 'hash',
base: __dirname,

View File

@ -11,8 +11,8 @@
<script>
var demo1 = xmSelect.render({
el: '#demo1',
radio: true,
clickClose: true,
radio: true,
clickClose: true,
model: {
icon: 'hidden',
label: {
@ -29,8 +29,8 @@ var demo1 = xmSelect.render({
var demo2 = xmSelect.render({
el: '#demo2',
radio: true,
clickClose: true,
radio: true,
clickClose: true,
theme: {
color: '#5FB878',
},

View File

@ -3,7 +3,12 @@
### 全局方法 get
:::warning
get方法默认返回的是符合条件的数组,
:::
```
//所有
xmSelect.get();
//字符串
@ -14,6 +19,8 @@ xmSelect.get(/demo.*/);
xmSelect.get((el) => {
return el == '#demo1' || el == '#xm3'
});
//获取单实例
xmSelect.get('#demo2', true);
```
:::demo
@ -26,6 +33,7 @@ xmSelect.get((el) => {
<div><button class="btn" id="btn2">get(字符串)</button></div>
<div><button class="btn" id="btn3">get(正则)</button></div>
<div><button class="btn" id="btn4">get(过滤方法)</button></div>
<div><button class="btn" id="btn5">get(获取单实例)</button></div>
<script>
@ -61,6 +69,11 @@ document.getElementById('btn4').onclick = function(){
});
alert('自定义方法的实例: ' + xmList.length)
}
document.getElementById('btn5').onclick = function(){
var demo2 = xmSelect.get('#demo2', true);
alert('获取单实例#demo2当前选中值: ' + demo2.getValue('nameStr'));
}
</script>
```
:::

View File

@ -172,7 +172,7 @@ list: [ "ALL", "CLEAR",
| 事件名 | 说明 | 参数 | 返回值 |
| ------ | ------------------ | -------- | -------- |
| render | 渲染多选 | (options: 配置项) | 实例对象 |
| get | 获取页面中已经渲染的多选 | (filter: 过滤`el`) | 符合条件的实例数组 |
| get | 获取页面中已经渲染的多选 | (filter: 过滤`el`, single: 是否返回单实例) | 符合条件的实例数组 |
| batch | 批量操作已渲染的多选 | (filter: 过滤`el`, method: 方法, ...方法参数) | 符合条件的实例数组 |
```
@ -186,6 +186,8 @@ xmSelect.get(/.*demo1.*/); //正则获取
xmSelect.get(function(el){
return el == '#demo1' || el == '#demo2';
});
//单实例
xmSelect.get('#demo2', true);
//batch 使用方式
//批量执行禁用

View File

@ -1,6 +1,6 @@
{
"name": "xm-select",
"version": "1.0.12",
"version": "1.0.13",
"description": "始于Layui的select多选解决方案",
"main": "index.js",
"scripts": {
@ -14,6 +14,7 @@
"@babel/preset-env": "^7.4.2",
"babel-loader": "^8.0.5",
"babel-plugin-transform-react-jsx": "^6.24.1",
"babel-polyfill": "^6.26.0",
"clean-webpack-plugin": "^3.0.0",
"cross-env": "^6.0.0",
"css-loader": "^3.0.0",

View File

@ -77,7 +77,7 @@ export function deepMerge(obj1, obj2) {
export function mergeArr(arr1, arr2, prop) {
let value = prop.value;
let result = [...arr2];
for (let i in arr1) {
for (let i = 0; i < arr1.length; i++) {
let item = arr1[i];
if (!arr2.find(a => a[value] == item[value])) {
result.push(item);

View File

@ -79,7 +79,7 @@ class xmOptions {
//更新渲染
this.update({ ...initData[initVal.el]});
//子组件初始化
childs[this.options.el].reset();
childs[this.options.el].reset(this.options, true);
return this;
}

View File

@ -21,12 +21,12 @@ class Framework extends Component{
this.bodyView = null;
}
reset(props){
reset(props, refresh = false){
//用于多选上限的边框颜色变化
this.updateBorderColor('');
let old = this.state.data;
this.resetDate(props.data);
JSON.stringify(props.data) !== JSON.stringify(old) && this.value(props.initValue ? props.initValue : this.findValue(this.state.data), !!this.state.show);
(JSON.stringify(props.data) !== JSON.stringify(old) || refresh) && this.value(props.initValue ? props.initValue : this.findValue(this.state.data), !!this.state.show);
}
findValue(data){

View File

@ -19,7 +19,7 @@ const xmSelect = {
}
return instance;
},
get(filter){
get(filter, single){
let type = Object.prototype.toString.call(filter);
let method;
switch (type){
@ -36,7 +36,8 @@ const xmSelect = {
break;
}
let keys = Object.keys(object)
return (method ? keys.filter(method) : keys).map(key => object[key]).filter(instance => selector(instance.options.el));
let list = (method ? keys.filter(method) : keys).map(key => object[key]).filter(instance => selector(instance.options.el));
return single ? list[0] : list;
},
batch(filter, method){
let args = [ ...arguments ];