You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.<
8000
/span>
You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
letmut img_list = document.find("img[src]");
img_list.for_each(|_index, ele| {// 如何删除符合要求的节点?// How should I remove the element});let svg = Vis::load("<svg></svg>").unwrap();// 如何把节点添加到document中?// How should I append this svg to the document?
Activity
tctco commentedon Aug 1, 2022
https://github.com/fefit/visdom#feature-flags
fefit commentedon Aug 1, 2022
@tctco 操作元素的方式和jq里操作DOM元素的方式类似,比如像下面这样:
可以参看节点操作的wiki,另外注意引入包的时候,feature必须开启
insertion(删除的话还需要开启destory),才能引入以上节点操作部分的代码。tctco commentedon Aug 1, 2022
谢谢!
还有一个问题,如果我想替换一个元素应该怎样做呢?
我既不熟悉jq也不熟悉rust :(
fefit commentedon Aug 1, 2022
@tctco 的确可以用
insert_before和remove两个方法来进行replace的操作,使用的方式大概类似不过这个方法针对
img元素失效了,这是个bug,我晚点来排查修复一下。另外这种替换的需求可能还是提供类似jq的replace_withAPI操作比较好,只需要一次操作就好,到时使用的方式大概类似:需要到晚点发版才能一并提供了。
tctco commentedon Aug 1, 2022
Cool! 期待.jpg
再次感谢!!!
feat: add method replace_with for elements, fix #10
fefit commentedon Aug 2, 2022
@tctco
replace_with方法已经在新发布的0.5.4版本中提供,并修复了insert_beforeimg 等标签不生效的问题。如果使用中还遇到啥问题,欢迎随时反馈!感谢!fix: fix insert mutation not working for some type of nodes, fix #10