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

如何采集网站文章表白软件制作器手机版

如何采集网站文章,表白软件制作器手机版,东莞公司网站建设,网站排名优化平台以下是整理后的 AntV X6 Vue 3 节点开发全流程指南,包含完整代码示例和关键实现细节: 环境搭建与项目初始化 使用 Vite 快速创建 Vue 3 项目: npm create vitelatest x6-vue-demo cd x6-vue-demo npm install安装核心依赖: n…

以下是整理后的 AntV X6 + Vue 3 节点开发全流程指南,包含完整代码示例和关键实现细节:

环境搭建与项目初始化

使用 Vite 快速创建 Vue 3 项目:

npm create vite@latest x6-vue-demo
cd x6-vue-demo
npm install

安装核心依赖:

npm install @antv/x6 @antv/layout @antv/x6-vue-shape element-plus

配置 Element Plus(在 main.js/ts 中):

import { createApp } from 'vue'
import App from './App.vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'const app = createApp(App)
app.use(ElementPlus)
app.mount('#app')

自定义节点组件开发

创建 NodeView.vue 组件:

<template><div class="node" @click="handleClick"><div class="node-title">{{ nodeData.name }}</div><div class="node-status">状态: {{ nodeData.status || "未执行" }}</div></div>
</template><script setup>
import { ref, onBeforeUnmount } from "vue"
const props = defineProps({ getNode: Function })
const node = props.getNode()
const nodeData = ref(node ? node.getData() : {})const handleChange = ({ current }) => {nodeData.value = { ...current }
}
if (node) node.on("change:data", handleChange)onBeforeUnmount(() => {if (node) node.off("change:data", handleChange)
})const handleClick = () => {alert(`点击了: ${nodeData.value.name}`)
}
</script><style scoped>
.node {width: 120px;height: 50px;background: #409eff;color: #fff;border-radius: 6px;display: flex;flex-direction: column;align-items: center;justify-content: center;font-size: 12px;cursor: pointer;
}
.node-title { font-weight: bold; }
.node-status { font-size: 10px; margin-top: 4px; }
</style>

主页面实现

创建 GraphDemo.vue 核心逻辑:

<template><div><el-button type="primary" @click="setStatus('成功')">父节点成功</el-button><el-button type="danger" @click="setStatus('失败')">父节点失败</el-button><el-button @click="setStatus('等待')">父节点等待</el-button><div class="graph-container" ref="graphRef"></div><TeleportContainer /></div>
</template><script setup>
import { ref, onMounted, defineComponent } from "vue"
import { Graph } from "@antv/x6"
import { register, getTeleport } from "@antv/x6-vue-shape"
import { DagreLayout } from "@antv/layout"
import NodeView from "../components/NodeView.vue"const graphRef = ref(null)
let graph = null
const TeleportContainer = defineComponent(getTeleport())const initGraph = () => {register({shape: "vue-node",component: NodeView,getComponentProps(node) {return { getNode: () => node }}})graph = new Graph({container: graphRef.value,background: { color: "#f9f9f9" },grid: true})const taskList = [{ id: "1", name: "任务A", status: "等待" },{ id: "2", name: "任务B", status: "等待" },{ id: "3", name: "任务C", status: "等待" }]const relations = [{ source: "1", target: "2" },{ source: "1", target: "3" }]const nodes = taskList.map((task) => ({id: task.id,shape: "vue-node",width: 120,height: 50,data: task}))const edges = relations.map((rel) => ({source: rel.source,target: rel.target,attrs: {line: {stroke: "#999",strokeWidth: 2,targetMarker: { name: "classic", width: 12, height: 8 }}}}))const layout = new DagreLayout({type: "dagre",rankdir: "LR",nodesep: 40,ranksep: 60})graph.fromJSON(layout.layout({ nodes, edges }))updateEdgesColor()
}const updateEdgesColor = () => {graph.getEdges().forEach((edge) => {const sourceNode = graph.getCellById(edge.getSourceCellId())const status = sourceNode?.getData()?.status || "等待"edge.setAttrs({line: { stroke: status === "成功" ? "green" :status === "失败" ? "red" : "gray"}})})
}const setStatus = (status) => {const parentNode = graph.getCellById("1")parentNode.setData({ ...parentNode.getData(), status })updateEdgesColor()
}onMounted(() => initGraph())
</script><style scoped>
.graph-container {width: 100%;height: 500px;border: 1px solid #ddd;margin-top: 10px;
}
</style>

关键功能说明

自动布局实现
通过 DagreLayout 自动计算节点位置,参数说明:

  • rankdir: "LR" 控制布局方向(Left to Right)
  • nodesepranksep 控制节点间距

动态边颜色控制
updateEdgesColor 方法根据源节点状态改变连线颜色:

  • 成功状态:绿色边
  • 失败状态:红色边
  • 默认状态:灰色边

节点数据响应式
通过监听 change:data 事件实现节点状态实时更新,注意在组件卸载时移除事件监听

效果说明

运行后可见:

  1. 三个采用自动布局排列的节点
  2. 父节点(任务A)控制两个子节点的边颜色
  3. 点击按钮可切换父节点状态(成功/失败/等待)
  4. 点击节点会显示节点名称提示框
http://www.dtcms.com/a/437798.html

相关文章:

  • 美耐皿 技术支持 东莞网站建设网站域名变更怎么查询
  • 网站app开发关于网站建设的英文书籍
  • 制作营销网站模板低价自适应网站建设优化建站
  • 网站seo文章该怎么写上海工商网查询官网
  • 网站怎么被百度收录门户网站建设项目招标
  • dede网站栏目管理网站设计建站
  • 南宁手机模板建站太原公司网站建设
  • django网站开发视频教程网上国网app下载安装
  • 外贸网站外链注册公司一年交多少税
  • 软件网站开发平台seo优化交流
  • 宁晋网站建设代理价格微信端怎么建设网站
  • 在哪个网站做一照一码页面模板下载
  • 国外网站页面设计网站开发层次
  • 菜鸟如何建网站中国企业500强怎么评的
  • 路北网站制作专业知识
  • 自己公司内网网站和外网怎么做同步教你如何用天翼云盘做网站
  • 网站建设制作官网深圳加盟网站建设
  • 推荐一些做电子的网站假冒中国建设银行的网站
  • 几何图形生成网站in什么 wordpress
  • 机械网站建设栏目内容云莱坞网站开发
  • wordpress 群站网站建设属于经营什么范围
  • 最优惠的手机网站建设东莞房价会涨吗
  • 周口学做网站哪些网站discuz做的
  • 个人网站可以挂广告吗注册公司代理费用
  • 网站制作 优帮云广东省建设信息港网站
  • 网站开发搭建购买了网站空间如何进入
  • 网站关键词先后wordpress 调用百度地图吗
  • html做电商网站如何推广品牌
  • 二手房中介网站模板大学it网页制作教程
  • 广州智能模板建站网站开发建设费用包括那些