为何从新设置points
属性然后调用draw
方法不会清空之前的绘制呢?
点击之后变成了两条线
<div id="container"></div>
<script src="./lib/jquery/dist/jquery.js" charset="utf-8"></script>
<script src="./lib/konva/konva.js" charset="utf-8"></script>
<script type="text/javascript">
$(function() {
const stage = new Konva.Stage({
container: '#container',
width: window.innerWidth,
height: window.innerHeight,
});
const layer = new Konva.Layer();
const line = new Konva.Line({
points: [10, 10, 100, 100],
stroke: 'black',
strokeWidth: 3,
});
line.on('click', event => {
line.points([10, 10, 100, 10]);
line.draw();
});
layer.add(line);
stage.add(layer);
});
</script>
达令说
相关分类