how to load data from text file to javascript array?

前端 未结 3 1112
失恋的感觉
失恋的感觉 2020-12-10 20:49

i have an array called items=[\"apple\",\"mango\",\"cherry\"];

i wonder how i can load the array data from text file instead of declaring it?the text f

3条回答
  •  孤街浪徒
    2020-12-10 21:40

     var file = event.target.file;
     var reader = new FileReader();
     var txt=reader.readAsText(file);
     var items=txt.split(",");
    

提交回复
热议问题