vue-cli 5.0 基于WEBPACK5发布 而WEBPACK5为了提升打包性能不再提供 NodeJS API Polyfill 的自动引入功能 webpack.docschina.org/blog/2020-1…
解决方式
1.安装webpack扩展
npm install -S webpack
2.修改vue.config.js
const webpack = require('webpack')
module.exports = defineConfig({
configureWebpack : {
plugins : [
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'], // ['包名', '包中的值']
})
]
}
})