详细问题描述
canvas绘制写在onLoad中H5不起作用,写在onReady中才正常
APP中都正常
重现步骤
<template>
<view>
<canvas canvas-id="myCanvas" style="border: 1px solid;"/>
<!-- <button type="primary" @tap="draw">绘画</button> -->
</view>
</template>
<script>
export default {
data() {
return {
}
},
onLoad() {
const ctx = uni.createCanvasContext('myCanvas')
ctx.setFillStyle('red')
ctx.fillRect(10, 10, 150, 75)
ctx.draw()
},
onReady() {
},
methods: {
}
}
</script>
<style>
</style>
IDE运行环境说明
[HBuilderX 2.1.1]
[Mac os 10.12.6]
uni-app运行环境说明
[H5]
[HBuilderX]
联系方式
[1213731560]