3***@qq.com
3***@qq.com
  • 发布:2022-08-10 11:06
  • 更新:2022-08-15 15:32
  • 阅读:168

【报Bug】vue3 wxs中ins.callMethod报错

分类:uni-app

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

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: 21H2 19044.1826

HBuilderX类型: 正式

HBuilderX版本号: 3.5.3

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

基础库版本号: 2.25.2

项目创建方式: HBuilderX

示例代码:
<template>  
    <view class="content">  
        <image @touchstart="wxsTest.t" class="logo" src="/static/logo.png"></image>  

    </view>  
</template>  
<script  module="wxsTest" lang="wxs">  
    function t(e,ins) {  
        ins.callMethod('onTest','')  
    }  
    module.exports = {  
        t:t  
    }  
</script>  
<script setup>  
    const onTest = ()=> {  
        console.log('ontest 111');  
    }   
</script>

操作步骤:

在wxs中 调用ins.callMethod()

预期结果:

打印 ontest 111

实际结果:

TypeError: this.$vm[callMethod] is not a function

bug描述:

VM9 asdebug.js:10 TypeError: this.$vm[callMethod] is not a function
at Bo.methods. [as onTest] (vendor.js?t=wechat&s=1660100202356&v=c614762c3963557f255cfb109202428d:5354)
at Tn (WASubContext.js?t=wechat&s=1660100202356&v=2.25.2:1)
at WASubContext.js?t=wechat&s=1660100202356&v=2.25.2:1
at J (WASubContext.js?t=wechat&s=1660100202356&v=2.25.2:1)
at WASubContext.js?t=wechat&s=1660100202356&v=2.25.2:1
at WAServiceMainContext.js?t=wechat&s=1660100202356&v=2.25.2:1
at a (VM9 asdebug.js:10)
at c (VM9 asdebug.js:10)
at VM9 asdebug.js:1
at Set.forEach ()(env: Windows,mp,1.06.2208010; lib: 2.25.2)

2022-08-10 11:06 负责人:无 分享
已邀请:
DCloud_UNI_LXH

DCloud_UNI_LXH

目前 wxs 不支持 setup script 用法,请使用:

<script>  
    export default {  
        setup() {  
            const onTest = () => {  
                console.log('ontest 111');  
            }  
            return {  
                onTest  
            }  
        }  
    }  
</script>

要回复问题请先登录注册