export default { data() { return { position: [], } }, computed: { pos() { return JSON.stringify(this.position) } }, watch: { show(newVal) { let valueObj = this.position[0] if (!valueObj) return valueObj.show = newVal valueObj.once_change = true; // console.log("show newVal:",newVal); this.$set(this.position, 0, valueObj) } }, mounted() { this.init() setTimeout(()=>{ this.getSize() },50) }, methods: { init() { //多个页面监听到这个方法时候,需要 判断是不是this uni.$on('__uni__swipe__event', (res) => { if (res !== this) { let valueObj = this.position[0] valueObj.show = false this.$set(this.position, 0, valueObj) }else{ //如果是自己,设置bshow this.bshow = true; // console.log("__uni__swipe__event",this.show); } // this.bshow = true; }) //开始设置隐藏 this.show = false }, openSwipe() { uni.$emit('__uni__swipe__event', this) }, change(e) { // this.$emit('change', e.close) let valueObj = this.position[0] valueObj.show = !e.close valueObj.once_change = false; // console.log("e.close:",e.close); this.$set(this.position, 0, valueObj) // console.log('改变', e); }, onClick(index, item) { this.$emit('click', { content: item, index }) }, getSize() { const views = uni.createSelectorQuery().in(this) views .selectAll('.selector-query-hock') .boundingClientRect(data => { data[0].show = false data[0].once_change = false; data[0].bInit = true; this.position = data }) .exec() } } }