Skip to content

Commit fe44b1e

Browse files
committed
fix: swipe-action 报错的bug
1 parent 832f4b8 commit fe44b1e

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

  • components/uni-swipe-action

‎components/uni-swipe-action/mp.js‎

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,45 @@
11
export default {
2-
data () {
2+
data() {
33
return {
44
position: [],
55
button: []
66
}
77
},
88
computed: {
9-
pos () {
9+
pos() {
1010
return JSON.stringify(this.position)
1111
},
12-
btn () {
12+
btn() {
1313
return JSON.stringify(this.button)
1414
}
1515
},
1616
watch: {
17-
show (newVal) {
17+
show(newVal) {
1818
if (this.autoClose) return
1919
let valueObj = this.position[0]
20+
if (!valueObj) {
21+
valueObj = []
22+
}
2023
valueObj.show = newVal
2124
this.$set(this.position, 0, valueObj)
2225
}
2326
},
2427
// #ifdef H5
25-
mounted () {
28+
mounted() {
2629
this.init()
2730
this.getSize()
2831
this.getBUttonSize()
2932
},
3033
// #endif
3134
// #ifndef H5
32-
onReady () {
35+
onReady() {
3336
this.init()
3437
this.getSize()
3538
this.getBUttonSize()
3639
},
3740
// #endif
3841
methods: {
39-
init () {
42+
init() {
4043
uni.$on('__uni__swipe__event', (res) => {
4144
if (res !== this && this.autoClose) {
4245
let valueObj = this.position[0]
@@ -45,23 +48,23 @@ export default {
4548
}
4649
})
4750
},
48-
openSwipe () {
51+
openSwipe() {
4952
uni.$emit('__uni__swipe__event', this)
5053
},
51-
change (e) {
54+
change(e) {
5255
this.$emit('change', e.open)
5356
let valueObj = this.position[0]
5457
valueObj.show = e.open
5558
this.$set(this.position, 0, valueObj)
5659
// console.log('改变', e);
5760
},
58-
onClick (index, item) {
61+
onClick(index, item) {
5962
this.$emit('click', {
6063
content: item,
6164
index
6265
})
6366
},
64-
getSize () {
67+
getSize() {
6568
const views = uni.createSelectorQuery().in(this)
6669
views
6770
.selectAll('.selector-query-hock')
@@ -75,7 +78,7 @@ export default {
7578
})
7679
.exec()
7780
},
78-
getBUttonSize () {
81+
getBUttonSize() {
7982
const views = uni.createSelectorQuery().in(this)
8083
views
8184
.selectAll('.button-hock')

0 commit comments

Comments
 (0)