-3
我有下面的代码,我想在运行时根据变量值来替换代码,我该如何实现这个使用JavaScript。由于Kony手机使用它,请忽略FormA,动画等。Javascript - 如何使用变量在运行时替换现有的代码
//desired out put inside the run time code.
FormA.ItemFlexContainer0.animate
//index has a value of 0 for now.
var index = 0;
var ItemFlexContainerString = "ItemFlexContainer"+index;
FormA.ItemFlexContainerString.animate
Error :- Type Error null is not an object
由于ItemFlexContainerString不存在,它会抛出错误。
,并在现有的问题是行不通提到的答案,FormCart [“ItemFlexContainer” +指数] .animate,数组应该用双引号索引作为书面附加到它。 – Max