- 当你在 @vue/composition-api 使用 createSelectorQuery 时获取不到 this, 则使用 getCurrentInstance 替换
- 演示代码:
import { getCurrentInstance } from '@vue/composition-api'
export default {
setup() {
const app = getCurrentInstance()
uni
.createSelectorQuery()
.in(app.proxy)
.select('#myCanvas')
.node(data => {
console.log(data) // 输出:{ nodeCanvasType: "2d", node: Cy }
})
.exec()
}
}
import { getCurrentInstance } from '@vue/composition-api'
export default {
setup() {
const app = getCurrentInstance()
uni
.createSelectorQuery()
.in(app)
.select('#myCanvas')
.node(data => {
console.log(data) // 输出:{ nodeCanvasType: "2d", node: Cy }
})
.exec()
}
}
0 个评论
要回复文章请先登录或注册