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

微信小程序中设置renderer问题,节点为image的问题 #127

Closed
WenHua39 opened this issue Mar 1, 2022 · 7 comments
Closed

微信小程序中设置renderer问题,节点为image的问题 #127

WenHua39 opened this issue Mar 1, 2022 · 7 comments

Comments

@WenHua39
Copy link

WenHua39 commented Mar 1, 2022

1、微信小程序中设置renderer:svg/canvas时报错container无效,但实际上官方文档写的是container可以不加或者设置为null,
2、自定义节点和内置节点,只要添加了image相关的,就会报错createImage这个方法不存在,但实际上antvis/f6-wx 的源码里面为什么会存在document.getElementById这种js的原生方法?这是把pc的或者h5的还是什么的源码拷过来没改掉?

@ICMI
Copy link
Collaborator

ICMI commented Mar 1, 2022

  1. 文档有些滞后,这个已有安排。参见
  2. image 相关接口,传入container为canvas实例即可,这个也是近期加的内容,还没补充文档。如果还没有解决问题,请附上具体报错截图

@WenHua39
Copy link
Author

WenHua39 commented Mar 1, 2022

1、那么想设置renderer为svg要传什么值呢?
2、defaultNode中 ,我使用了自定义节点,自定义节点中按照api添加modelRect节点,配置了两个icon对象,里面分别有img属性,会报错creatImage不存在,这个也是('#container')造成这个dom节点不存在造成的吧?这时候container需要传什么,有例子可看么?
return group.addShape("modelRect", {
// 节点中 icon 配置
logoIcon: {
// 是否显示 icon,值为 false 则不渲染 icon
show: true,
x: 0,
y: 0,
// icon 的地址,字符串类型
img: "https://gw.alipayobjects.com/zos/basement_prod/4f81893c-1806-4de4-aff3-9a6b266bc8a2.svg",
width: 16,
height: 16,
// 用于调整图标的左右位置
offset: 0,
},
// 节点中表示状态的 icon 配置
stateIcon: {
// 是否显示 icon,值为 false 则不渲染 icon
show: true,
x: 0,
y: 0,
// icon 的地址,字符串类型
img: "https://gw.alipayobjects.com/zos/basement_prod/300a2523-67e0-4cbf-9d4a-67c077b40395.svg",
width: 16,
height: 16,
// 用于调整图标的左右位置
offset: -5,
},
})
渲染

@WenHua39
Copy link
Author

WenHua39 commented Mar 1, 2022

设置节点modelRect,不传container会报这个错误
VM1096 WAService.js:2 TypeError: o[i] is not a constructor
at e.addShape (index.js?t=wechat&s=1646104170949&v=d1e9ed1c75792d154c4b9c40ff631f25:46)
at Object.draw (index.js? [sm]:77)
at Object.draw (index.js?t=wechat&s=1646104170949&v=d1e9ed1c75792d154c4b9c40ff631f25:16)
at e.t.drawInner (index.js?t=wechat&s=1646104170949&v=d1e9ed1c75792d154c4b9c40ff631f25:16)
at e.t.draw (index.js?t=wechat&s=1646104170949&v=d1e9ed1c75792d154c4b9c40ff631f25:16)
at e.t (index.js?t=wechat&s=1646104170949&v=d1e9ed1c75792d154c4b9c40ff631f25:16)
at new e (index.js?t=wechat&s=1646104170949&v=d1e9ed1c75792d154c4b9c40ff631f25:16)
at t.addItem (index.js?t=wechat&s=1646104170949&v=d1e9ed1c75792d154c4b9c40ff631f25:16)
at n.e.addItem (index.js?t=wechat&s=1646104170949&v=d1e9ed1c75792d154c4b9c40ff631f25:16)
at n.innerAddChild (index.ts:104)(env: macOS,mp,1.05.2201240; lib: 2.19.4)

传container就会报 那个creatImage不存在的错误

@ICMI
Copy link
Collaborator

ICMI commented Mar 1, 2022

1、 小程序端不支持svg, 除非用webview加载h5
2、 container 的值传的是 canvas实例,参见

@WenHua39
Copy link
Author

WenHua39 commented Mar 1, 2022

好的,谢谢
但是modelRect 这个报错还是存在的TypeError: o[i] is not a constructor,这块压缩的源码看不出来是哪里造成的

@ICMI
Copy link
Collaborator

ICMI commented Mar 1, 2022

按理说不应该报错了,我这边用例试过了, container 正常传canvas实例进去,是没问题

@WenHua39
Copy link
Author

WenHua39 commented Mar 2, 2022

那可能是我使用的姿势不对,我再试试,感谢

@ICMI ICMI closed this as completed Mar 4, 2022
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

2 participants