gpt4 book ai didi

javascript - 尝试将字符串作为函数参数传递给 SVG

转载 作者:行者123 更新时间:2023-11-28 10:02:47 25 4
gpt4 key购买 nike

我正在尝试动态创建此函数:

svg.path($('#shape23'), 
path.move(333,410)
.smoothC(333,410,333,410)
.smoothC(217.5,415.75,217.5,415.75)
.smoothC(333,500,333,500)
.close(), {fill: '#CCCCCC'});

...第二个参数的变量值(从 path.move 到 close()):

var myPath = 'path.move(333,410)';
myPath += '.smoothC(333,410,333,410)';
myPath += '.smoothC(217.5,415.75,217.5,415.75)';
myPath += '.smoothC(333,500,333,500)';
myPath += '.close()';

svg.path($('#shape23'), myPath, {fill: '#CCCCCC'});

...但是我遇到了解析错误。

在我拔掉剩余的头发之前,有人可以帮忙吗?

最佳答案

试试这个

svg.path($('#shape23'), eval(myPath),  {fill: '#CCCCCC'});

关于javascript - 尝试将字符串作为函数参数传递给 SVG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8899522/

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