解决在Nuxt3+naiveUi中打包出现vueuc导入方式问题报错

在nuxt3+naiveui项目中打包出现vueuc导入方式问题报错,导致页面访问500。

错误描述

[nuxt] [request error] [unhandled] [500] Named export 'VBinder' not found. The requested module 'vueuc' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'vueuc';
const { resizeObserverManager, VResizeObserver, VirtualList, VFollower, VBinder, VTarget, VOverflow, VFocusTrap } = pkg;

解决方式:

nuxt.config.ts 文件中添加如下代码:

 build: { transpile: ['naive-ui', "vueuc"] },

欢迎访问我的博客:张苹果博客(Nuxt3+naiveUI):https://zhangpingguo.com/

你可能感兴趣的:(前端)