Comments (7)
Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it.
To help make it easier for us to investigate your issue, please follow the contributing guidelines.
We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.
from x6.
使用 https://www.npmjs.com/package/vue2-teleport 改写一下 https://github.com/antvis/X6/blob/master/packages/x6-vue-shape/src/teleport.ts 或许可以
from x6.
如果觉得改写 x6-vue-shape有难度,可以参考https://github.com/lloydzhou/x6-html-shape写一个 vue2-teleport的版本,这个改起来比较简单。
from x6.
@lloydzhou 我这里试着改了一下,但是Object.keys(items)拿到的总是个空数组
import { h, reactive, markRaw } from '@vue/composition-api';
import { Fragment } from 'vue-fragment';
import Teleport from 'vue2-teleport';
import type { Graph } from '@antv/x6';
import type { VueShape } from '@antv/x6-vue-shape';
import Vue, { type VueConstructor } from 'vue';
let active = false;
const items = reactive<{ [key: string]: VueConstructor<Vue> }>({});
export function connect(id: string, component: VueConstructor<Vue>, node: VueShape, graph: Graph) {
if (active) {
// eslint-disable-next-line vue/one-component-per-file
const vm = Vue.extend({
provide: () => ({
getNode: () => node,
getGraph: () => graph
}),
render: () =>
h(
Teleport,
{
attrs: {
to: '#test-teleport' // 测试
}
},
[
h(component, {
props: {
node,
graph
}
})
]
)
});
items[id] = markRaw(vm);
}
}
export function disconnect(id: string) {
if (active) {
delete items[id];
}
}
export function isGraphActive() {
return active;
}
function getVNodes(): Promise<VNode[]> {
return new Promise(resolve => {
const VNodes = Object.keys(items).map(id => h(items[id]));
resolve(VNodes);
});
}
export async function getTeleport(): Promise<VueConstructor<Vue>> {
active = true;
const VNodes = await getVNodes();
return new Promise(resolve => {
// eslint-disable-next-line vue/one-component-per-file
const vm = Vue.extend({
render: () => h(Fragment, {}, VNodes)
});
resolve(vm);
});
}
from x6.
@lloydzhou 另外这里好像不需要自己connet了,因为可以直接拿到shapeMaps ,值和items是一样的,不过在Object.kyes时也是个空的
import { shapeMaps } from '@antv/x6-vue-shape'
export async function getTeleport(): Promise<VueConstructor<Vue>> {
return new Promise(resolve => {
const vm = Vue.extend({
render: () => h(Fragment, {}, Object.keys(shapeMaps).map(id => h(shapeMaps[id])))
});
resolve(vm);
});
}
from x6.
shapeMaps不是vue里面的reactive的变量,只是一个常量。所以在vue里面使用的时候,如果值变化了,组件并不会更新
from x6.
@lloydzhou 嗯嗯,后面还是用的items,但是没啥效果,渲染不到teleport上
from x6.
Related Issues (20)
- @a-silent-guy 所以还是建议如果要保留边的话,可以先通过 `edge.setSource` 或者 `edge.setTarget` 等方法先将边和节点解绑。 HOT 2
- 自定义vue节点如何把数据传递给父级? HOT 14
- 如何调整桩点(vertices)与连线上按钮(button)的层级 HOT 3
- 请问用1x好还是2x HOT 2
- 使用React节点重绘画布时会报Warning: Attempted to synchronously unmount a root while React was already rendering HOT 3
- 自定义节点数据更新视图无法更新 HOT 16
- Edge/router中ExcludeNodes在fromJson后似乎失效 HOT 1
- 1.35.0 版本, 在创建 图形界面的时候 使用 new Function(t),涉及 csp,unsafe-eval 执行代码。 新版本是否已经修正 HOT 1
- 2.x版本 Stencil插件在 collapsable=false 时会遮挡第一组抬头
- 2.x 在使用scroller 插件后 没法去改变画布的大小 使用graph.options.height = 300 类似这种操作 可以修改画布大小 但是不会被记录到历史记录插件中。 HOT 1
- 已经连接到节点的边可以再移动么 HOT 2
- 可以调整最小对齐网格吗?现在是10,期望调整到5最好能到1 HOT 2
- 给群组提供一个tooltip HOT 1
- dagrelayout:Uncaught (in promise) RangeError: Maximum call stack size exceeded
- antv x6初始化画布报错Uncaught TypeError: Class constructor Ph cannot be invoked without 'new' HOT 2
- 内核版本 126+,embedding 方法移动到父节点中,父节点外侧的 g 标签会无限扩大 HOT 2
- 导出图片Error: size exceeded HOT 5
- 拖拽高亮边框持续变大 HOT 1
- createEdge 返回 zIndex 无效 HOT 1
- 自定义vue节点重复渲染问题解决方案
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from x6.