vue 使用xlsx出现"export 'default' (imported as 'XLSX') was not found in 'xlsx'报错

虽然提示错误,但功能还能正常使用,但每次看这报错也有点不舒服

解决方法:

将xlsx版本更改为0.16.0

yarn add [email protected]
npm install [email protected] --save

使用过程中如果出现 Error: Cannot read properties of undefined (reading ‘read‘) at FileReader.read 无法使用xlsx的read方法
同时终端也出现"export 'default' (imported as 'XLSX') was not found in 'xlsx',

解决:

直接将import XLSX from 'xlsx'改为import * as XLSX from 'xlsx/xlsx.mjs'即可

参考文档
vue2中引入XLSX插件,出现“export ‘default‘ (imported as ‘XLSX‘) was not found in ‘xlsx‘_不会掉头发的小白的博客-CSDN博客_vue xlsx插件

你可能感兴趣的:(vue 使用xlsx出现"export 'default' (imported as 'XLSX') was not found in 'xlsx'报错)