page: 📄 添加和移出事件

This commit is contained in:
bunny 2024-07-12 10:08:27 +08:00
parent 1a1bb6893d
commit 0ceec1f86d
1 changed files with 3 additions and 1 deletions

View File

@ -15,6 +15,7 @@ import { Circle } from 'konva/lib/shapes/Circle';
const { width, height } = useWindowSize(); const { width, height } = useWindowSize();
const circle = ref<Circle>(); const circle = ref<Circle>();
const text = ref<Text>(); const text = ref<Text>();
const count = ref(0);
const initial = () => { const initial = () => {
const stage = new Konva.Stage({ container: 'container', width: width.value, height: height.value }); const stage = new Konva.Stage({ container: 'container', width: width.value, height: height.value });
@ -44,7 +45,8 @@ const initial = () => {
// //
circle.value?.on('click', function () { circle.value?.on('click', function () {
text.value?.text('点击了'); text.value?.text(`点击了:${count.value}`);
count.value++;
}); });
stage.add(layer); stage.add(layer);