落魄实习生
落魄实习生
  • 发布:2022-02-22 10:27
  • 更新:2022-06-10 10:07
  • 阅读:1758

【报Bug】Vue3 renderjs无法调用this.$ownerInstance.callMethod的方法

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

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

HBuilderX类型: Alpha

HBuilderX版本号: 3.3.8

手机系统: Android

手机系统版本号: Android 6.0

手机厂商: 模拟器

手机机型: MUMU模拟器

页面类型: vue

vue版本: vue3

打包方式: 云端

项目创建方式: HBuilderX

示例代码:
<template>  
    <view class="content">  
        <image class="logo" src="/static/logo.png"></image>  
        <view class="text-area">  
            <text class="title">{{ title }}</text>  
        </view>  
    </view>  
</template>  

<script>  
export default {  
    data() {  
        return {  
            title: 'Hello'  
        };  
    },  
    onLoad() {},  
    methods: {  
        test(e) {  
            console.log(e)  
        }  
    }  
};  
</script>  

<script module="localStorage" lang="renderjs">  
export default {  
    mounted() {  
        this.$ownerInstance.callMethod('test', 'test')  
        // for (var i = 0; i < localStorage.length; i++) {  
        //  var key = localStorage.key(i); // 获取本地存储的Key  
        //  var value = localStorage.getItem(key); // 获取本地存储的value  
        //  that.$ownerInstance.callMethod('restructureLocalStorage', {key,value})  
        // }  
    }  
}  
</script>  

<style>  
.content {  
    display: flex;  
    flex-direction: column;  
    align-items: center;  
    justify-content: center;  
}  

.logo {  
    height: 200rpx;  
    width: 200rpx;  
    margin-top: 200rpx;  
    margin-left: auto;  
    margin-right: auto;  
    margin-bottom: 50rpx;  
}  

.text-area {  
    display: flex;  
    justify-content: center;  
}  

.title {  
    font-size: 36rpx;  
    color: #8f8f94;  
}  
</style>  

操作步骤:

HBuilderx 3.3.8直接新建项目编写renderjs示范

预期结果:

通过renderjs的ownerInstance.callMethod调用逻辑层方法,提示:Cannot read property 'callMethod' of undefined

实际结果:

通过renderjs的ownerInstance.callMethod调用逻辑层方法,提示:Cannot read property 'callMethod' of undefined

bug描述:

Vue3 renderjs无法调用this.$ownerInstance.callMethod的方法

2022-02-22 10:27 负责人:DCloud_UNI_FXY 分享
已邀请:
FullStack

FullStack - 【插件开发】【专治疑难杂症】【ios上架、马甲包、白包、过审、已成功上架过几百个】【多款插件已上架:https://ext.dcloud.net.cn/publisher?id=22130】【非诚勿扰】QQ:543610866

已验证,确实存在

DCloud_UNI_FXY

DCloud_UNI_FXY

预计 HBuilderX Alpha 3.3.13 修复

  • a***@gmail.com

    Vue 3 使用 <script setup>时还是存在该问题

    2022-04-29 14:31

  • DCloud_UNI_FXY

    回复 a***@gmail.com: 发完整的测试代码

    2022-04-29 15:05

  • t***@163.com

    回复 DCloud_UNI_FXY:


    <template>

    <view>

    </view>

    </template>


    <script setup>

    function haha(){

    console.log('hahahhahahha')

    }

    </script>

    <script module="test" lang="renderjs">

    export default {

    mounted() {

    this.$ownerInstance.callMethod('haha')

    },

    }

    </script>

    <style>


    </style>

    2022-07-04 17:14

  • t***@163.com

    vue3组合式api还是有问题,需要修复一下

    2022-07-04 17:15

9***@qq.com

9***@qq.com

Vue 3 使用 <script setup>时还是存在该问题

要回复问题请先登录注册