收藏
回答

getFileSystemManager.writeFile写json字符为doc时乱码?

//写文件

var treeData={"id":1455,"pid":0,"tpid":1455,"word":"asas","examine":0,"interpretation":"asassa","open":true,"nodes":[{"id":1486,"pid":1455,"tpid":1455,"word":"你们","interpretation":null,"open":false},{"id":1487,"pid":1455,"tpid":1455,"word":"u……这种天气真的","interpretation":null,"open":false}]};

var fsm = wx.getFileSystemManager();

var filePath = wx.env.USER_DATA_PATH + '/' + treeData.word + '.doc';

var content = JSON.stringify(treeData);

console.log(content);

fsm.writeFile({

filePath: filePath,

data: content,

encoding: 'utf8',

success: function(res) {

wx.downloadFile({

url: filePath,

success: function(res) {

wx.openDocument({

filePath: res.tempFilePath

});

}

});

}

});

回答关注问题邀请回答
收藏
登录 后发表内容
问题标签