Skip to content

Commit 515863a

Browse files
dpp0507007insummer
authored andcommitted
fix: 修改checkbox组件属性命名规则 (#538)
1 parent ee8ff31 commit 515863a

File tree

8 files changed

+32
-26
lines changed

8 files changed

+32
-26
lines changed

dist/checkbox-group/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ Component({
2121
value: 'column', //column row
2222
},
2323
// 最多选中值
24-
max: {
24+
maxSelected: {
2525
type: [Number,null],
2626
value: null
2727
},
28-
min: {
28+
minSelected: {
2929
type: [Number,null],
3030
value: null
3131
}
3232
},
3333
data: {
3434
},
3535
attached() {
36-
let { min, max} = this.properties;
37-
this.checkMax(min, max);
36+
let { minSelected, maxSelected} = this.properties;
37+
this.checkMax(minSelected, maxSelected);
3838
},
3939
methods: {
4040

dist/checkbox/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ Component({
7474
const parent = this.getRelationNodes('../checkbox-group/index')[0];
7575

7676
if(this.properties.checked) {
77-
if(this.isOverflow('min')) return;
77+
if(this.isOverflow('minSelected')) return;
7878
} else {
79-
if(this.isOverflow('max')) return;
79+
if(this.isOverflow('maxSelected')) return;
8080
}
8181

8282
const item = {
@@ -95,12 +95,14 @@ Component({
9595
*/
9696
isOverflow(type) {
9797
const parent = this.getRelationNodes('../checkbox-group/index')[0];
98+
9899
const limit = parent.properties[type];
99100
if (!limit) return false;
100101
const selectedLength = Object.values(parent._selected).length;
101-
let isOverflow = type === 'min' ? selectedLength <= limit : selectedLength >= limit;
102+
let isOverflow = type === 'minSelected' ? selectedLength <= limit : selectedLength >= limit;
102103
if (isOverflow) {
103-
parent.onEmitOverflowHandle && parent.onEmitOverflowHandle({key: this.properties.key, number: limit, type: `overflow_${type}`});
104+
let backType = type === 'minSelected' ? 'min_selected' : 'max_selected';
105+
parent.onEmitOverflowHandle && parent.onEmitOverflowHandle({key: this.properties.key, limitNumber: limit, type: `overflow_${backType}`});
104106
}
105107
return isOverflow;
106108
}

examples/dist/checkbox-group/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ Component({
2121
value: 'column', //column row
2222
},
2323
// 最多选中值
24-
max: {
24+
maxSelected: {
2525
type: [Number,null],
2626
value: null
2727
},
28-
min: {
28+
minSelected: {
2929
type: [Number,null],
3030
value: null
3131
}
3232
},
3333
data: {
3434
},
3535
attached() {
36-
let { min, max} = this.properties;
37-
this.checkMax(min, max);
36+
let { minSelected, maxSelected} = this.properties;
37+
this.checkMax(minSelected, maxSelected);
3838
},
3939
methods: {
4040

examples/dist/checkbox/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ Component({
7474
const parent = this.getRelationNodes('../checkbox-group/index')[0];
7575

7676
if(this.properties.checked) {
77-
if(this.isOverflow('min')) return;
77+
if(this.isOverflow('minSelected')) return;
7878
} else {
79-
if(this.isOverflow('max')) return;
79+
if(this.isOverflow('maxSelected')) return;
8080
}
8181

8282
const item = {
@@ -95,12 +95,14 @@ Component({
9595
*/
9696
isOverflow(type) {
9797
const parent = this.getRelationNodes('../checkbox-group/index')[0];
98+
9899
const limit = parent.properties[type];
99100
if (!limit) return false;
100101
const selectedLength = Object.values(parent._selected).length;
101-
let isOverflow = type === 'min' ? selectedLength <= limit : selectedLength >= limit;
102+
let isOverflow = type === 'minSelected' ? selectedLength <= limit : selectedLength >= limit;
102103
if (isOverflow) {
103-
parent.onEmitOverflowHandle && parent.onEmitOverflowHandle({key: this.properties.key, number: limit, type: `overflow_${type}`});
104+
let backType = type === 'minSelected' ? 'min_selected' : 'max_selected';
105+
parent.onEmitOverflowHandle && parent.onEmitOverflowHandle({key: this.properties.key, limitNumber: limit, type: `overflow_${backType}`});
104106
}
105107
return isOverflow;
106108
}

examples/pages/components/form/pages/checkbox/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ Page({
204204
},
205205

206206
tipOverflow(data) {
207-
let title = data.detail.type === 'overflow_max' ? `最多选择${data.detail.number}个` : `至少选择${data.detail.number}个`;
207+
let title = data.detail.type === 'overflow_max_selected' ? `最多选择${data.detail.limitNumber}个` : `至少选择${data.detail.limitNumber}个`;
208208
wx.showToast({
209209
title: title,
210210
icon: 'none',

examples/pages/components/form/pages/checkbox/index.wxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
>
210210
<view class='buttun-wrapper'>
211211
<view class='title'>10. 下面哪些演员获得影帝称号?</view>
212-
<l-checkbox-group bind:linchange="change" min="2" max="3" bind:linout="tipOverflow" data-index="10">
212+
<l-checkbox-group bind:linchange="change" min-selected="2" max-selected="3" bind:linout="tipOverflow" data-index="10">
213213
<l-checkbox
214214
l-class="l-checkbox-color"
215215
wx:for="{{items10}}"

src/checkbox-group/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ Component({
2121
value: 'column', //column row
2222
},
2323
// 最多选中值
24-
max: {
24+
maxSelected: {
2525
type: [Number,null],
2626
value: null
2727
},
28-
min: {
28+
minSelected: {
2929
type: [Number,null],
3030
value: null
3131
}
3232
},
3333
data: {
3434
},
3535
attached() {
36-
let { min, max} = this.properties;
37-
this.checkMax(min, max);
36+
let { minSelected, maxSelected} = this.properties;
37+
this.checkMax(minSelected, maxSelected);
3838
},
3939
methods: {
4040

src/checkbox/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ Component({
7474
const parent = this.getRelationNodes('../checkbox-group/index')[0];
7575

7676
if(this.properties.checked) {
77-
if(this.isOverflow('min')) return;
77+
if(this.isOverflow('minSelected')) return;
7878
} else {
79-
if(this.isOverflow('max')) return;
79+
if(this.isOverflow('maxSelected')) return;
8080
}
8181

8282
const item = {
@@ -95,12 +95,14 @@ Component({
9595
*/
9696
isOverflow(type) {
9797
const parent = this.getRelationNodes('../checkbox-group/index')[0];
98+
9899
const limit = parent.properties[type];
99100
if (!limit) return false;
100101
const selectedLength = Object.values(parent._selected).length;
101-
let isOverflow = type === 'min' ? selectedLength <= limit : selectedLength >= limit;
102+
let isOverflow = type === 'minSelected' ? selectedLength <= limit : selectedLength >= limit;
102103
if (isOverflow) {
103-
parent.onEmitOverflowHandle && parent.onEmitOverflowHandle({key: this.properties.key, number: limit, type: `overflow_${type}`});
104+
let backType = type === 'minSelected' ? 'min_selected' : 'max_selected';
105+
parent.onEmitOverflowHandle && parent.onEmitOverflowHandle({key: this.properties.key, limitNumber: limit, type: `overflow_${backType}`});
104106
}
105107
return isOverflow;
106108
}

0 commit comments

Comments
 (0)