Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在运行时将 JavaScript 代码初始化为字符串变量。如何执行存储的 JavaScript 代码。
您可以使用eval
eval
var code = "alert('sdfdf');"; eval(code); // this will execute the code inside the string