我的代码片段:
function receive(mag)
{
var text = eval(mag);
alert(text);
}
receive('["magnolia,", ["Magnolia (Flower)"], [], [], [], [], [], [[3, 19019, "INV_MAG_39 ", 5]]]');
当我在示例中传递字符串时(如上所示),eval(mag)
它不起作用。但如果我直接这样做:
function receive(mag)
{
var text = eval('["magnolia,", ["Magnolia (Flower)"], [], [], [], [], [], [[3, 19019, "INV_MAG_39 ", 5]]]');
alert(text);
}
它确实有效。有谁知道出了什么问题/我怎样才能让它与传递的变量一起工作?