getFileSystemManager.writeFile写json字符为doc时乱码?
发布于 6 年前 作者 gangren 9313 次浏览 来自 官方Issues

//写文件

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

						});

					}

				});

			}

		});
回到顶部