世上仅此一个正确答案……请结贴
JS读写文件,分别如下://读文件
function readFile(filename){
var fso = new ActiveXObject("Scripting.FileSystemObject")
var f = fso.OpenTextFile(filename,1)
var s = ""
while (!f.AtEndOfStream)
s += f.ReadLine()+"\n"
f.Close()
return s
}
//读文件
function readFile(filename){
var fso = new ActiveXObject("Scripting.FileSystemObject")
var f = fso.OpenTextFile(filename,1)
var s = ""
while (!f.AtEndOfStream)
s += f.ReadLine()+"\n"
f.Close()
return s
}
//写文件
function writeFile(filename,filecontent){
var fso, f, s
fso = new ActiveXObject("Scripting.FileSystemObject")
f = fso.OpenTextFile(filename,8,true)
f.WriteLine(filecontent)
f.Close()
alert('ok')
}
解决思路:将List转成json,传到界面。js中使用vararr=eval(‘${list}')将list转成js数组。参考代码如下:varkeyList=eval('${keysList}')varvalues=$("#paramsValues").val()varnoSet=[]for(vari=0i<keyList.lengthi++){if(values.indexOf(keyList[i])==-1){noSet.push(keyList[i])}}