a***@163.com
a***@163.com
  • 发布:2022-01-10 17:49
  • 更新:2022-01-10 19:27
  • 阅读:453

TypeError: undefined is not a function (near '...view.node...') __ERROR canvas节点获取报错

分类:uni-app
<template>  
    <view style="height: 100%; width: 100%;">  
        <canvas type="webgl" canvas-id="c" id="c" @touchstart="touchStart" @touchmove="touchMove" @touchend="touchEnd"></canvas>  
    </view>  
</template>  
<script>  
    import * as THREE from '../../libs/three.weapp.js'  
    export default {  
        data() {  
            return {  
                canvas: '',  
            }  
        },  
        mounted() {  
            let view = uni.createSelectorQuery().in(this).select("#c")  
            // view.boundingClientRect(data => {  
            //   console.log("得到布局位置信息" + JSON.stringify(data));  
            //   console.log("节点离页面顶部的距离为" + data.top);  
            // }).exec();  
            view.node((res) => {  
                console.log(res)  
                const canvas = new THREE.global.registerCanvas(res.node)  
                loadObj(canvas, THREE)  
            }).exec()  

        },  

    }  
</script>  

<style lang="scss">  
    #c {  
        width: 100%;  
        height: 100%;  
    }  
</style>
2022-01-10 17:49 负责人:无 分享
已邀请:
a***@163.com

a***@163.com (作者)

nodesRef.boundingClientRect(callback) 获取倒是没问题

a***@163.com

a***@163.com (作者)

这是手机测试时boundingClientRect()和node()返回打印出来数据,node返回的对象里node属性为null?用开发工具时node属性就有节点信息,canvas我也给id了

该问题目前已经被锁定, 无法添加新回复