🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
``` //读取txt文档 var path = "D:/编辑0000文字.txt"; var myFile = new File(path); if (myFile != null) { // open file var fileOK = myFile.open("r"); if (fileOK){ var text; var arrayText = new Array(); while (!myFile.eof){ text = myFile.readln(); if (text == "") text = "\r" ; arrayText.push(text); } // close the file before exiting myFile.close(); } else{ alert("文件打开失败!"); } }else{ alert("请先选择txt文件."); } ```