如何在 konva js 中覆盖(或更新)宽度和 hiehgt 的形状?
how to overwrite ( or update) shape of width and hiehgt in konva js?
我在我的项目中使用了 konva js。我对如何更新形状宽度和高度的现有值有疑问。
例如:
var stage = new Konva.Stage({
container: 'container',
width: width,
height: height,
fill: "white",
});
var layer = new Konva.Layer();
stage.add(layer);
var bg = new Konva.Rect({
x: 0,
y: 0,
width:width ,
height:height ,
fill: 'white',
draggable: false,
});
layer.add(bg);
// ---------------------------------
var update_shape=()=>{
//i want to update here <-------------just calling this function
}
现在我想动态更新上面的宽度和高度值
shape.width(newWidth);
// or
shape.setAttr('width', newWidth);
// or
shape.setAttrs({ width: newWidth });
我在我的项目中使用了 konva js。我对如何更新形状宽度和高度的现有值有疑问。
例如:
var stage = new Konva.Stage({
container: 'container',
width: width,
height: height,
fill: "white",
});
var layer = new Konva.Layer();
stage.add(layer);
var bg = new Konva.Rect({
x: 0,
y: 0,
width:width ,
height:height ,
fill: 'white',
draggable: false,
});
layer.add(bg);
// ---------------------------------
var update_shape=()=>{
//i want to update here <-------------just calling this function
}
现在我想动态更新上面的宽度和高度值
shape.width(newWidth);
// or
shape.setAttr('width', newWidth);
// or
shape.setAttrs({ width: newWidth });