[# Perfect solution to node.js error after modularization ReferenceError: require is not defined]

Perfect solution to node.js error after modularization ReferenceError: require is not defined

The error message is as shown in the figure

Directly change the plug-in source code: (not the plug-in in cnpm, but the downloaded export2Excel.js)

Just change the header line of source code in export2Excel.js.

改之前:
/* eslint-disable */
require('script-loader!file-saver');//保存文件用
require('script-loader!@/excel/Blob');//转二进制用
// require('./Blob');//转二进制用
require('script-loader!xlsx/dist/xlsx.core.min');//xlsx核心
...
改成:
/* eslint-disable */
require('script-loader!file-saver');//保存文件用
// require('script-loader!@/excel/Blob');//转二进制用
require('./Blob');//转二进制用
require('script-loader!xlsx/dist/xlsx.core.min');//xlsx核心

Guess you like

Origin blog.csdn.net/qq_62124267/article/details/133820322