function file() {
var fs = api.require('fs');
fs.open({
path: 'widget://res/config.json',
flags: 'read_write'
}, function(ret, err) {
if (ret.status) {
fs.read({
fd: ret.fd,
offset: 0,
length: 0
}, function(ret_1, err_1) {
} else {
alert(JSON.stringify(err_1));
}
});
} else {
alert(JSON.stringify(err));
}
});
}
var fs = api.require('fs');
fs.open({
path: 'widget://res/config.json',
flags: 'read_write'
}, function(ret, err) {
if (ret.status) {
fs.read({
fd: ret.fd,
offset: 0,
length: 0
}, function(ret_1, err_1) {
if (ret_1.status) {
//调用函数处理JSON
} else {
alert(JSON.stringify(err_1));
}
});
} else {
alert(JSON.stringify(err));
}
});
}