canvas难道只能在wxss里规定高度和宽度么?

发布于 6 年前作者 songyong7106 次浏览最后编辑 6 年前来自 ask

我在wxml文件里定义:

<canvas canvas-id=“arcCanvas” class=“canvasStyle”></canvas>

下面是wxss文件里规定的canvas

.canvasStyle {

width:100%;

height: 500px;

margin-top: 10px;

border-radius: 50%;

background: #023;

}

如何用js文件规定他的高度和宽度呢?

我想在js文件里动态根据需求定义canvas的高度和宽度

2 回复
bqiu
bqiu1 楼6 年前

<canvas style=“width:{{width}}px”></canvas>

juantian
juantian2 楼4 年前

你的单位被狗吃了,o( ̄ヘ ̄o#)