forever2020
forever2020
  • 发布:2020-11-25 18:47
  • 更新:2020-11-25 18:47
  • 阅读:6481

运行的时候总是报fs.readFileSync is not a function

分类:uni-app

在vue页面中的script添加:
var fs = require('fs');
var image = fs.readFileSync(url).toString("base64");

运行的时候总是报错:
[system]TypeError: fs.readFileSync is not a function
at Function.success (webpack-internal:///./node_modules/babel-loader/lib/index.js!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader/index.js?!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader/index.js?!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-uni-app-loader/using-components.js!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/index.js?!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-scoped-loader/index.js!.)
at http://localhost:8080/static/js/chunk-vendors.js:319:78854
at Object.A [as callback] (http://localhost:8080/static/js/chunk-vendors.js:319:81663)
at b (http://localhost:8080/static/js/chunk-vendors.js:319:82500)
at XMLHttpRequest.w.onload (http://localhost:8080/static/js/chunk-vendors.js:319:51359)

这个问题困扰了一天了,求解答!~

2020-11-25 18:47 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复