gpt4 book ai didi

javascript - 函数 getById Raphael js

转载 作者:行者123 更新时间:2023-11-30 05:54:22 24 4
gpt4 key购买 nike

其次,我使用 raphaeljs 库在不同路径中进行了 SVG 形式转换。
我想通过raphaeljs 2.1.0 => getById(id);
的功能调用他来获取路径但是 Chrome 或 Firefox 告诉我没有函数 getById !我不明白为什么?

这是我的一段代码:

rsrGroups = [path_c_trsp,path_i_trsp,path_l_trsp,path_o_trsp];
len = rsrGroups.length;

for(var i = 0; i < len; i++){
var el = rsrGroups[i];

el.mouseover(function() {
rsrGroupsMin.forEach(function(el){
var getPath = el.getById('el.id'); // here is the method called !
alert(getPath);
el.animate({opacity: 0.5},350,function () {});
rsrGroups2.forEach(function(tri){
tri.animate({opacity: 0.5},350,function () {});
});
});
this.animate({opacity: 1},350,function () {});
});
}

这是 Chrome 给出的错误:

Uncaught TypeError: Object Raphaël’s object has no method 'getById'

我尝试了不同的方法,但没有一个有效:/

最佳答案

getById 是纸张对象的方法,而不是元素,即

var paper = Raphael(10, 50, 320, 200);
paper.getById('id')

或者如果您无权访问 paper 变量,您可以调用 el.paper.getById

关于javascript - 函数 getById Raphael js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12855366/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com