当前位置: 首页 > news >正文

AntvX6-shape2

前言

使用 shape 插件的时候需要传递数据

代码

1、容器
<!-- container.vue -->
<template><div id="container"></div>
</template>
<script setup lang="ts">
import { Graph } from "@antv/x6";
import { onMounted } from "vue";
import { register } from "@antv/x6-vue-shape";
import elmNode from "./elmNode.vue";register({shape: "elm-vue-node",component: elmNode,
});onMounted(() => {const graph = new Graph({container: document.getElementById("container"),width: "800",height: "800",});graph.addNode({shape: "elm-vue-node",data: {classType: "test", //需要传递到子组件的数据},});
});
</script>
2、组件
<!-- elmNode.vue -->
<template><div>{{ label }}</div><div class="node-main"></div>
</template>
<script setup lang='ts'>
import { inject, onMounted } from "vue-demi";const getNode = inject("getNode");	//用来接收容器的数据
let node = getNode();	//组件数据
let data = node.getData();	//传递的数据
let label = data["classType"];
</script>
<style lang='less' scoped>
.node-main {width: 61px;height: 92px;background-image: url("../../assets/site.svg");background-size: 61px 92px;
}
</style>

效果

在这里插入图片描述


http://www.mrgr.cn/news/11604.html

相关文章:

  • Linux开发环境搭建,虚拟机安装
  • <数据集>车牌识别数据集<目标检测>
  • 一起学习LeetCode热题100道(55/100)
  • 语音控制开关的语音识别ic芯片方案
  • Mybatis中的缓存
  • Android广播的分类和使用
  • C#—多线程
  • 【jvm】栈是否存在垃圾回收
  • v4l2(video4linux2) yuyv(yuv422)、MJPEG、H.264
  • yocto | 基于Linux的定制系统跑Qt app(第一集)
  • 【精选】基于Python的热门旅游景点数据分析系统的设计与实现(南京旅游,北京旅游,旅游网站,全国各地旅游网站)
  • Hugo博客搭建
  • 数据库集群技术
  • 我写的全部R包和函数,持续更新中
  • 【网络安全】绕过输入验证
  • 博弈论详解 1(基本理论定义 和 Nim 游戏)
  • 基于python的pytest单元测试框架
  • PyTorch构建模型网络结构的6种方式
  • 游戏开发设计模式之原型模式
  • 设置虚拟机使用主机以太网而不是WiF连接