尝试在Vite中使用lib“react-inlinesvg”。 我有这样的代码:
<SVG src={require(`../../../assets/icons/icon/logo_${themeProp}_full.svg`)} />;
结果我有:
react-inlinesvg.js?v=ee63b9bd:1002 Uncaught (in promise) TypeError: Cannot convert object to primitive value
at RegExp.exec (<anonymous>)
at react-inlinesvg.js?v=ee63b9bd:1002:62
at react-inlinesvg.js?v=ee63b9bd:1083:7
at commitHookEffectListMount (chunk-MCEUSTYS.js?v=05c8fdba:16902:34)
at commitPassiveMountOnFiber (chunk-MCEUSTYS.js?v=05c8fdba:18150:19)
at commitPassiveMountEffects_complete (chunk-MCEUSTYS.js?v=05c8fdba:18123:17)
at commitPassiveMountEffects_begin (chunk-MCEUSTYS.js?v=05c8fdba:18113:15)
at commitPassiveMountEffects (chunk-MCEUSTYS.js?v=05c8fdba:18103:11)
at flushPassiveEffectsImpl (chunk-MCEUSTYS.js?v=05c8fdba:19484:11)
at flushPassiveEffects (chunk-MCEUSTYS.js?v=05c8fdba:19441:22)
我在Vite配置中添加了常见的js插件,但它没有改变任何东西
检查
themeProp
的值,它应该是一个字符串