小程式 writeFile引數filePath要怎麼寫
阿新 • • 發佈:2021-01-07
技術標籤:小程式小程式javascript
// 在本地使用者檔案目錄下建立一個檔案 hello.txt,寫入內容 "hello, world"
const fs = wx.getFileSystemManager()
fs.writeFileSync(`${wx.env.USER_DATA_PATH}/hello.txt`, 'hello, world', 'utf8')
// 寫入圖片
fsm.writeFile({
filePath:`${wx.env.USER_DATA_PATH}/a.jpg`,
data: buffer,
encoding: 'binary',
success() {
// resolve(filePath);
wx.getImageInfo({
src: `${wx.env.USER_DATA_PATH}/a.jpg`,
success: function (res) {
console.log(res)
resolve(res);
},
})