提交 3dfd94fc 编写于 作者: H hdx

nodes-info: TODO 修复响应式警告问题

上级 f6a0a744
...@@ -39,24 +39,51 @@ ...@@ -39,24 +39,51 @@
</template> </template>
<script> <script>
type NodeInfoType = {
left : number | null,
top : number | null,
right : number | null,
bottom : number | null,
width : number | null,
height : number | null,
}
export default { export default {
data() { data() {
return { return {
title: 'createSelectorQuery', title: 'createSelectorQuery',
nodeInfoList: [] as NodeInfo[], nodeInfoList: [] as NodeInfoType[],
} }
}, },
methods: { methods: {
getNodeInfo() { getNodeInfo() {
uni.createSelectorQuery().select('.rect1').boundingClientRect().exec((ret) => { uni.createSelectorQuery().select('.rect1').boundingClientRect().exec((ret) => {
this.nodeInfoList.length = 0 this.nodeInfoList.length = 0
this.nodeInfoList.push(ret[0] as NodeInfo) const i = ret[0]! as NodeInfo
this.nodeInfoList.push({
left: i.left,
top: i.top,
right: i.right,
bottom: i.bottom,
width: i.width,
height: i.height,
} as NodeInfoType)
}) })
}, },
getAllNodeInfo() { getAllNodeInfo() {
uni.createSelectorQuery().selectAll('.rect').boundingClientRect().exec((ret) => { uni.createSelectorQuery().selectAll('.rect').boundingClientRect().exec((ret) => {
this.nodeInfoList.length = 0 this.nodeInfoList.length = 0
this.nodeInfoList.push(...(ret[0] as NodeInfo[])) const array = ret[0]! as NodeInfo[]
array.forEach((i) => {
this.nodeInfoList.push({
left: i.left,
top: i.top,
right: i.right,
bottom: i.bottom,
width: i.width,
height: i.height,
} as NodeInfoType)
})
}) })
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册