Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0.4版本如何获取到graph对象 #408

Closed
WangJM001 opened this issue Nov 15, 2019 · 17 comments
Closed

2.0.4版本如何获取到graph对象 #408

WangJM001 opened this issue Nov 15, 2019 · 17 comments

Comments

@WangJM001
Copy link

请问2.0.4版本如何获取到graph对象?
需要调用toDataUrl方法

@JYC-99
Copy link

JYC-99 commented Nov 15, 2019

通过ref可以拿到

const { graph } = yourGGEditorComponentRef.current;

@WangJM001
Copy link
Author

没有current属性啊,是在哪个组件上ref,GGEditor?还是子组件Mind?
image

@JYC-99
Copy link

JYC-99 commented Nov 18, 2019

没有current属性啊,是在哪个组件上ref,GGEditor?还是子组件Mind?
image

应该是在的refs上能拿到。
至于current,我代码里用的createRef 如果是直接拿ref的话就没有,不用在意这种细节哈哈。

@WangJM001
Copy link
Author

感谢,先实现功能吧,3.0应该也快了

@WangJM001
Copy link
Author

好像不是原生的graph对象,没有toDataUrl属性

@Anonlyy
Copy link

Anonlyy commented Nov 28, 2019

@WangJM001 你好解决了吗,老哥

@WangJM001
Copy link
Author

我项目的需求是搞定了,后来换成g6-editor了,也已经不维护了,你现在是什么问题,我看看能不能帮助到你

@Anonlyy
Copy link

Anonlyy commented Nov 28, 2019

一样的功能, 就是想要调用 downloadImage()、toDataUrl() 实现下载功能,谢谢老哥

@WangJM001
Copy link
Author

这些是g6 3.0的api,2.0.4版本用的是g6 2.0+

@Anonlyy
Copy link

Anonlyy commented Nov 28, 2019

所以不支持是吗?有其他办法实现吗

@WangJM001
Copy link
Author

const image =page.saveExpandImage() // mind
const image =page.saveImage(); // flow
const base64ImgData = image.toDataURL('image/png');

@WangJM001
Copy link
Author

你试试吧,不确定有没有,因为我后来换g6editor了,感觉这个版本有一些bug、g6editor好用些

@WangJM001
Copy link
Author

你可以把editor对象打印出来看看,文档都没写,里面应该有相应的方法,上面的方法就是我在g6editor里找到的
gg-editor-core应该类似g6editor

@Anonlyy
Copy link

Anonlyy commented Nov 28, 2019

好的谢谢老哥我试试

@WangJM001
Copy link
Author

WangJM001 commented Nov 28, 2019

忘了贴了
const page = editor.getCurrentPage();
editor可以重propsAPI取到

@Anonlyy
Copy link

Anonlyy commented Nov 28, 2019

太棒了,谢谢老哥,可以了哈哈
牛批!!

@tombsmrliu
Copy link

赞一个 我还以为我那个功能没希望了。对了我在额外引入g6库项目不能运行你们遇到过吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants