在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)
这个问题困扰了一天了,求解答!~
0 个回复