行。我想要做的是通过webviewstring传递一个数组。为此,我使用块将列表项加入到:[" item1"," item2"," item3"]。我通过了,并定义了这个:
var itemlist = window.AppInventor.getWebViewString();
但是当我尝试在数组中调用第0项时,它会给我这个:[
和第1项,它会给出"
,而第2项则会给出i
。
如果我使用
document.getElementById("list0").innerHTML = itemlist;
返回["item1", "item2", "item3"];
我认为发生的是它将整个webviews字符串放在括号内:(["item1", "item2", "item3"];
),所以当我调用itemlist时,它也会在结尾处返回;
。
有谁能告诉我如何将我的webviewstring转换为数组?
答案 0 :(得分:0)
我的建议是将csv格式的数据从App Inventor传递到HTML文件
然后将其转换为HTML文件中的数组,如下所示
// get the table to display from the window.AppInventor object and split at new line
var urlArray = window.AppInventor.getWebViewString().split("\n");
另见完整示例here