糖分至上
糖分至上
  • 发布:2024-07-20 23:21
  • 更新:2024-07-30 07:49
  • 阅读:130

【报Bug】renderjs 获取参数问题

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win 11 23H2

HBuilderX类型: 正式

HBuilderX版本号: 4.23

手机系统: Android

手机系统版本号: Android 13

手机厂商: 小米

手机机型: 小米10s 等

页面类型: vue

vue版本: vue3

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

代码如下

<view class="body">  
                <view v-for="(item,index) in questionList" :key="index" @tap="xxcp.hIndex(index)"  
                      :class="[{'al':questionList[index].answer},{'currentQuestion':cIndex===index+1}]">  
                    {{ item.Index }}  
                </view>  
</view>
hIndex(m_index){  
            let vs = [];  
            try{  
                let inputs = document.querySelectorAll('input');  
                    // 遍历所有的input。获取所有value  
                    inputs.forEach(item => {  
                        console.log(item.value)  
                        if (item.value !== '') vs.push(item.value);  
                        else vs.push(' ');  
                })  
            }catch (e){}  
            console.log(JSON.stringify(m_index))  
            console.log(JSON.stringify(vs))  
            this.$ownerInstance.callMethod('handleIndex', {m_index,vs})  
}

操作步骤:
<view class="body">  
                <view v-for="(item,index) in questionList" :key="index" @tap="xxcp.hIndex(index)"  
                      :class="[{'al':questionList[index].answer},{'currentQuestion':cIndex===index+1}]">  
                    {{ item.Index }}  
                </view>  
</view>
hIndex(m_index){  
            let vs = [];  
            try{  
                let inputs = document.querySelectorAll('input');  
                    // 遍历所有的input。获取所有value  
                    inputs.forEach(item => {  
                        console.log(item.value)  
                        if (item.value !== '') vs.push(item.value);  
                        else vs.push(' ');  
                })  
            }catch (e){}  
            console.log(JSON.stringify(m_index))  
            console.log(JSON.stringify(vs))  
            this.$ownerInstance.callMethod('handleIndex', {m_index,vs})  
}

预期结果:

我这里只是传递了一个如“0”,“1”这样的索引,但是打印出来的确实一堆属性

实际结果:
{"target":{"dataset":{"v-813b6529":"","v813b6529":""},    
"id":"",    
"offsetLeft":286,"offsetTop":76},    
"type":"click",    
"timeStamp":8628.300000011921,"detail":{"y":73,"x":296},    
"currentTarget":{"dataset":{"v-813b6529":"","v813b6529":""},    
"id":"","offsetLeft":286,"offsetTop":76},    
"changedTouches":[{"clientX":296,    
"pageY":73,    
"pageX":296,"force":1,    
"clientY":73,"identifier":0}],    
"touches":[{"clientX":296,"pageY":73,"pageX":296,"force":1,"clientY":73,"identifier":0}]}

bug描述:

使用renderjs向外传递了一个名为“m_index”的参数,在h5端就是自己想获取的内容,但是在app端就是一个包含了很多信息的内容,并不是我自己传递的值,请问这是什么系统保留变量吗,经过打印发现在renderjs内部此参数就已经不是我需要的参数了

{"target":{"dataset":{"v-813b6529":"","v813b6529":""},    
"id":"",    
"offsetLeft":286,"offsetTop":76},    
"type":"click",    
"timeStamp":8628.300000011921,"detail":{"y":73,"x":296},    
"currentTarget":{"dataset":{"v-813b6529":"","v813b6529":""},    
"id":"","offsetLeft":286,"offsetTop":76},    
"changedTouches":[{"clientX":296,    
"pageY":73,    
"pageX":296,"force":1,    
"clientY":73,"identifier":0}],    
"touches":[{"clientX":296,"pageY":73,"pageX":296,"force":1,"clientY":73,"identifier":0}]}

偶尔的时候还是报错renderjs中的方法找不到

2024-07-20 23:21 负责人:无 分享
已邀请:
BFC

BFC

你好,renderjs 中的methods 不支持传参, 默认只传event对象

  • 糖分至上 (作者)

    啊,可是我别的倒函数里传了参数它没报错呀

    2024-07-29 21:53

套马杆的套子

套马杆的套子 - 没有解决不了的问题,只有解决不完的问题

可以使用:change:prop,参数改变时,会触发方法拿到新老参数值

要回复问题请先登录注册