秋刀鱼会过期
秋刀鱼会过期
  • 发布:2024-08-27 11:38
  • 更新:2026-04-30 11:18
  • 阅读:477

【报Bug】uni.canvasToTempFilePath IOS APP 不进success fail complete

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Mac

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

HBuilderX类型: 正式

HBuilderX版本号: 4.07

手机系统: iOS

手机系统版本号: iOS 17

手机厂商: 苹果

手机机型: iphone 14 pro max

页面类型: vue

vue版本: vue2

打包方式: 离线

项目创建方式: HBuilderX

示例代码:
//html <canvas style="{width: canvasW + 'px', height: canvasH + 'px'}" class="canvas"
id="canvas"
canvas-id="canvas"
disable-scroll="true"
@touchstart="canvasStart"
@touchmove="canvasMove"
@touchend="canvasEnd"
@touchcancel="canvasEnd"
@error="canvasIdErrorCallback">
</canvas>
//js
console.log(uni.canvasToTempFilePath) //返回的是个fun
uni.canvasToTempFilePath({
canvasId: 'canvas',
success: function(response) {
console.log(response)
},
fail: function(fail) {
console.log(fail)
},
complete: function(complete) {
console.log(complete)
}
})

操作步骤:

在cavas中写了字之后,生成图片

预期结果:

可以进入uni.canvasToTempFilePath

实际结果:

无法进入该api

bug描述:

2024-08-27 11:38 负责人:无 分享
已邀请:
DCloud_UNI_yuhe

DCloud_UNI_yuhe

感谢反馈,已发现问题,正在查看是什么原因导致的

  • 秋刀鱼会过期 (作者)

    将必填的canvasId: 'canvas',故意写错为canvasid: 'canvas', 会进入fail,告知canvasId为必填参数,缺少这个参数

    2024-08-27 11:49

DCloud_UNI_yuhe

DCloud_UNI_yuhe

你好,我刚才测试是正常的了,可能是用法不对,你可以尝试以下下面的示例代码,看看是否正常。

<template>  
    <view>  
        <canvas id="firstCanvas" canvas-id="firstCanvas" style="width: 300px; height: 200px;"></canvas>  
        <button @click="cas">cas</button>  
    </view>  
</template>  

<script>  
export default {  
    onReady: function (e) {  
        var context = uni.createCanvasContext('firstCanvas')  
        context.setStrokeStyle("#00ff00")  
        context.setLineWidth(5)  
        context.rect(0, 0, 200, 200)  
        context.stroke()  
        context.setStrokeStyle("#ff0000")  
        context.setLineWidth(2)  
        context.moveTo(160, 100)  
        context.arc(100, 100, 60, 0, 2 * Math.PI, true)  
        context.moveTo(140, 100)  
        context.arc(100, 100, 40, 0, Math.PI, false)  
        context.moveTo(85, 80)  
        context.arc(80, 80, 5, 0, 2 * Math.PI, true)  
        context.moveTo(125, 80)  
        context.arc(120, 80, 5, 0, 2 * Math.PI, true)  
        context.stroke()  
        context.draw()  
    },  
    methods: {  
        canvasIdErrorCallback: function (e) {  
            console.error(e.detail.errMsg)  
        },  
        cas(){  
            uni.canvasToTempFilePath({  
              x: 100,  
              y: 200,  
              width: 50,  
              height: 50,  
              destWidth: 100,  
              destHeight: 100,  
              canvasId: 'firstCanvas',  
              success: function(res) {  
                console.log(res.tempFilePath)  
              }  
            })  

        }  
    }  
}  
</script>  

<style>  

</style>  

或者是你也可以提供一下你的代码

秋刀鱼会过期

秋刀鱼会过期 (作者) - 及时行乐

这是我删除掉一部分请求的vue文件 你可以看一下

2***@qq.com

2***@qq.com

遇到同样的问题

要回复问题请先登录注册