canvas_20 旋转

canvas_20 旋转

<template>
    <view class="zcvs">

        <view class="zcvs-item">
            <view>Canvas_旋转</view>
            <view>
                <canvas canvas-id="cvs" id="cvs" style="width: 400px; height: 400px;border: 1px solid #007AFF;" />
            </view>

        </view>

    </view>
</template>

<script>
    export default {
        data() {
            return {};
        },
        onReady() {
            this.drawCvs();
        },
        methods: {
            drawCvs() {
                const ctx = uni.createCanvasContext('cvs');
                ctx.setFillStyle("#007AFF");

                ctx.beginPath();
                ctx.translate(200, 0);
                ctx.rotate(30 * Math.PI / 180);
                ctx.fillRect(0, 0, 100, 100);

                ctx.draw();
            },
        }
    }
</script>

<style lang="scss" scoped></style>

 

上一篇:vue 双向数据绑定 v-model


下一篇:vue在methods里面跳转新页面&传递参数