You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
zhangpaopao0609
changed the title
nuxt3 下变量 global 编译成 globalThis 导致使用 global.value.xx 报错
nuxt3 下变量 global 替换成 globalThis 导致使用 global.value.xx 报错
Aug 11, 2022
tdesign-vue-next 版本
是
重现链接
https://codesandbox.io/s/nuxt3-tdesign-vue-next-tqoe07?file=/app.vue
重现步骤
使用框架和版本
如何复现
在 nuxt 中使用 pagination 组件,会直接报类似
Cannot read properties of undefined (reading 'jumpTo')
的错误补充说明
相关 issue:
[Pagination] 组件在nuxt3中运行报错: #988
问题定位
经过调试和查看 nuxt 源码发现, tdesign-vue-next 中的
global
会被 nuxt 替换成globalThis
,调试
因此,
global.value
的结果是globalThis.value
,而 globalThis 在 nuxt 中为全局对象,因此globalThis.value
为undefined
,所以global.value.xxx
都会出错:计划如何解决
global 在 nuxt 中会被替换成 globalThis,有两种解决办法
我个人更倾向于第二种,因为 global 在服务端确实是关键字来着
The text was updated successfully, but these errors were encountered: