这个是小程序的 代码片段 https://developers.weixin.qq.com/s/di2GTvmp7aA7
readFileSync 转换图片base64找不到路径?小程序设置微信背景图片的时候,无法引用本地图片,所以需要转换喂base64的格式, let aa = 'data:image/png;base64,' + wx.getFileSystemManager().readFileSync('../index/login-bg.png','base64'); console.log(aa) 我的图片的路径是在index文件夹下的。[图片] 但是会报下面的错误 WAServiceMainContext.js:9 Error: readFileSync:fail permission denied, open ../index/login-bg.png at Di (WAServiceMainContext.js:9) at Object.r.<computed> (WAServiceMainContext.js:9) at Object.t.<computed> [as readFileSync] (WAServiceMainContext.js:9) at xo.onLoad (index.js? [sm]:4) at xo.<anonymous> (WASubContext.js?t=wechat&s=1656919390203&v=2.24.7:23) at xo.i.__callPageLifeTime__ (WASubContext.js?t=wechat&s=1656919390203&v=2.24.7:23) at WASubContext.js?t=wechat&s=1656919390203&v=2.24.7:23 at WAServiceMainContext.js:9 at WASubContext.js?t=wechat&s=1656919390203&v=2.24.7:23 at WAServiceMainContext.js:9(env: Windows,mp,1.05.2204250; lib: 2.24.7)
2022-07-04