我有一个来自外部来源的数组,除非我从日志背面复制并粘贴,否则Javascript无法识别它。
因此,例如,以下代码将为 outside 输出一个字符串而不是一个数组,但是如果我从日志中为 outside 复制了确切的输出并为其分配了它,手动添加到新变量 copyfromlog ,它将作为数组输出。
var outside = Drupal.settings.map.loc_json;
// Directly copied from output of previous
var copyfromlog = [
[
"<div class='test china'><h2>Fake School</h2><hr><p>Lorem Ipsum.</p></div>",
54.345014,
-1.265579,
"school.png",
],
[
"<div class='test europe'><h2>Test School</h2><hr><p>Lorem Ipsum.</p></div>",
53.345014,
-6.265579,
"school.png",
],
];
console.log(outside);
console.log(copyfromlog);