文档
安装

安装

pnpm

pnpm add react-barcode-scanner

yarn

yarn add react-barcode-scanner

npm

npm install react-barcode-scanner

脚手架

Vite

建议使用最新版本的 Vite。如果 Vite 4 或更低版本无法预构建 ESM-only polyfill,可以将上游依赖排除在依赖优化之外:

export default defineConfig({
  optimizeDeps: {
    exclude: ['@preflower/barcode-detector-polyfill']
  }
})

🙏 感谢 @louispotok (opens in a new tab) 对本章节的帮助