page: 📄 将圆形zIndex设置为1

This commit is contained in:
bunny 2024-07-16 16:40:50 +08:00
parent 07762aec41
commit 4a19611284
2 changed files with 55 additions and 1 deletions

View File

@ -1,6 +1,5 @@
```sh ```sh
https://konvajs.org/docs/groups_and_layers/Layering.html https://konvajs.org/docs/groups_and_layers/Layering.html
https://konvajs.org/docs/groups_and_layers/Change_Containers.html
https://konvajs.org/docs/groups_and_layers/zIndex.html https://konvajs.org/docs/groups_and_layers/zIndex.html
https://konvajs.org/docs/tweens/Linear_Easing.html https://konvajs.org/docs/tweens/Linear_Easing.html

View File

@ -0,0 +1,55 @@
<script setup lang="ts">
import { useWindowSize } from '@vueuse/core';
import Konva from 'konva/lib';
import { onMounted, ref } from 'vue';
import { Circle } from 'konva/lib/shapes/Circle';
const { width, height } = useWindowSize();
const circle = ref<Circle>();
const initial = () => {
const stage = new Konva.Stage({ container: 'container', width: width.value, height: height.value });
const layer = new Konva.Layer();
stage.add(layer);
const group = new Konva.Group();
layer.add(group);
circle.value = new Konva.Circle({
x: 70,
y: 70,
fill: 'red',
radius: 30,
});
group.add(circle.value);
const blackRect = new Konva.Rect({
x: 20,
y: 20,
fill: 'black',
width: 100,
height: 100,
});
group.add(blackRect);
};
/**
* * 将圆形zIndex设置为1
*/
const updateCircle = () => {
circle.value!.zIndex(1);
};
onMounted(() => {
initial();
});
</script>
<template>
<div class="container-fluid">
<button class="btn btn-primary" @click="updateCircle">将圆形zIndex设置为1</button>
<div id="container"></div>
</div>
</template>
<style scoped lang="scss"></style>