itmonkey
itmonkey
  • 发布:2022-02-08 16:03
  • 更新:2022-02-08 16:42
  • 阅读:576

【报Bug】vue3下 wxs小程序端 callMethod 无效

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: w10

HBuilderX类型: 正式

HBuilderX版本号: 3.3.10

第三方开发者工具版本号: 1.0.5

基础库版本号: 2.19.2

项目创建方式: HBuilderX

示例代码:

wxs 文件

function touchstartEvent(e, ins) {  
	console.log('touchstartEvent');  
	 ins.callMethod('wxsCall', 'touchstartEvent')  
}  
  
function touchmoveEvent(e, ins) {  
	console.log('touchmoveEvent');  
	 ins.callMethod('wxsCall', 'touchmoveEvent')  
}  
  
function touchendEvent(e, ins) {  
	console.log('touchendEvent');  
	 ins.callMethod('wxsCall', 'touchendEvent')  
}  
  
  
  
module.exports = {  
	// propObserver: propObserver,  
	// callObserver: callObserver,  
	touchstartEvent: touchstartEvent,  
	touchmoveEvent: touchmoveEvent,  
	touchendEvent: touchendEvent  
}

vue文件

<template>  
	<view class="container wxs-demo" @touchstart="wxsTest.touchstartEvent" @touchmove="wxsTest.touchmoveEvent"  
		@touchend="wxsTest.touchendEvent" @touchcancel="wxsTest.touchendEvent">  
  
	</view>  
</template>  
  
  
<!-- 微信小程序, QQ小程序, app, h5使用wxs -->  
<!-- #ifdef MP-WEIXIN || MP-QQ || APP-PLUS || H5 -->  
<script src="./test.wxs" module="wxsTest" lang="wxs"></script>  
<!-- #endif -->  
<script setup>  
  
const wxsCall = (data)=>{  
	console.log(data,2222222);  
}  
  
</script>  
  
<style lang="scss" scoped>  
	.wxs-demo{  
		width: 500rpx;  
		height: 500rpx;  
		background-color: red;  
	}  
</style>

操作步骤:

如示例代码,封装为组件引用,在vue3环境下,H5端可以触发回调,小程序端无反应

预期结果:

小程序端 wxs 文件触发回调

实际结果:

小程序端 wxs 方法回调无法触发

bug描述:

wxs文件在组件中引用,小程序端 wxs中的callMethod 无法调用,触发不了组件中定义的方法

2022-02-08 16:03 负责人:无 分享
已邀请:
DCloud_UNI_Anne
  • itmonkey (作者)

    好的


    2022-02-08 17:25

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