提交 1d7a2075 编写于 作者: H hdx

create-selector-query: 适配微信

上级 59a33514
...@@ -90,13 +90,15 @@ ...@@ -90,13 +90,15 @@
fieldsResultContainNode: false, fieldsResultContainNode: false,
nodeResultContainNode: false nodeResultContainNode: false
} }
},
onLoad() {
uni.$on('childReady', this.onChildReady)
},
onUnload() {
uni.$off('childReady', this.onChildReady)
}, },
onReady() { onReady() {
const instance2 = (this.$refs['multi-child'] as ComponentPublicInstance) this.testFields()
this.selectCount = instance2.$data['selectCount'] as number
this.selectAllCount = instance2.$data['selectAllCount'] as number
this.testFields()
this.testNode() this.testNode()
}, },
onResize() { onResize() {
...@@ -109,7 +111,13 @@ ...@@ -109,7 +111,13 @@
} }
} */ } */
}, },
methods: { methods: {
// 仅用于自动化测试
onChildReady() {
const instance2 = (this.$refs['multi-child'] as ComponentPublicInstance);
this.selectCount = instance2.$data['selectCount'] as number;
this.selectAllCount = instance2.$data['selectAllCount'] as number;
},
// 仅用于自动化测试 // 仅用于自动化测试
getRootNodeInfo(selector : string) { getRootNodeInfo(selector : string) {
uni.createSelectorQuery().select(selector).boundingClientRect().exec((ret) => { uni.createSelectorQuery().select(selector).boundingClientRect().exec((ret) => {
......
...@@ -21,7 +21,8 @@ ...@@ -21,7 +21,8 @@
viewCount: 0, viewCount: 0,
selectCount: 0, selectCount: 0,
selectAllCount: 0, selectAllCount: 0,
show: false show: false,
testCounter: 0
} }
}, },
mounted() { mounted() {
...@@ -29,14 +30,25 @@ ...@@ -29,14 +30,25 @@
this.text1 = JSON.stringify(ret, null, 2) this.text1 = JSON.stringify(ret, null, 2)
if (ret.length == 1) { if (ret.length == 1) {
this.selectCount = ret.length this.selectCount = ret.length
} }
this.testCounter++
this._dispatchEvent()
}) })
uni.createSelectorQuery().in(this).selectAll('.selector-query-view').boundingClientRect().exec((ret) => { uni.createSelectorQuery().in(this).selectAll('.selector-query-view').boundingClientRect().exec((ret) => {
this.text2 = JSON.stringify(ret, null, 2) this.text2 = JSON.stringify(ret, null, 2)
if (ret.length == 1) { if (ret.length == 1) {
this.selectAllCount = (ret[0] as NodeInfo[]).length this.selectAllCount = (ret[0] as NodeInfo[]).length
} }
this.testCounter++
this._dispatchEvent()
}) })
},
methods: {
_dispatchEvent() {
if (this.testCounter == 2) {
uni.$emit('childReady')
}
}
} }
} }
</script> </script>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册