-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