
记electron-vue读取本地文件资源
vue
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
项目地址:https://gitcode.com/gh_mirrors/vu/vue

·
一.通过fs模块
const fs = require('fs');
const filePath = '';
fs.readFile(filePath, 'utf8', (err, data) => {
if (err) {
console.error(err);
return;
}
// 处理读取到的文件数据
console.log(data);
})
二.通过获取流 返回一次性链接
url="http://xxxx/test.png";
dir="D:/files"
let topPictureUrl = url.substr(url.lastIndexOf("/") + 1);
let p_uint8Buffer = Uint8Array.from(
fs.readFileSync(dir + "/" + topPictureUrl)
);
let bolb = new Blob([p_uint8Buffer]);
this.allFileData.topPictureUrl = URL.createObjectURL(bolb);
三.绝对路径(打包后)
<img src="/12309Files/240117109337972310016/856d87a072171c488aae17f41455c4c.png" alt="">




vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
最近提交(Master分支:5 个月前 )
9e887079
[skip ci] 4 个月前
73486cb5
* chore: fix link broken
Signed-off-by: snoppy <michaleli@foxmail.com>
* Update packages/template-compiler/README.md [skip ci]
---------
Signed-off-by: snoppy <michaleli@foxmail.com>
Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com> 7 个月前
更多推荐
所有评论(0)