We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
158行 左右的初始化函数中,会先从 localStorage 中读取modelId,并将其转换为数字类型(number | null)。但如果 localStorage.getItem('modelId') 返回的是 null(即该键不存在),似乎仍然会把它转换成 Number,导致结果会是 NaN 而不是 null。 这就会导致 162行 的 if (modelId === null) 判断出错。 我的解决方法是直接去掉 === null ,改为直接判断 modelId 变量的值是否为假值。 原始代码:
modelId
(number | null)
localStorage.getItem('modelId')
null
NaN
if (modelId === null)
=== null
(function initModel() { let modelId: number | null = Number(localStorage.getItem('modelId')); let modelTexturesId: number | null = Number( localStorage.getItem('modelTexturesId'), ); if (modelId === null) { // 首次访问加载 指定模型 的 指定材质 modelId = 1; // 模型 ID modelTexturesId = 53; // 材质 ID }
修改后:
(function initModel() { let modelId: number | null = Number(localStorage.getItem('modelId')); let modelTexturesId: number | null = Number( localStorage.getItem('modelTexturesId'), ); if (!modelId) { // 首次访问加载 指定模型 的 指定材质 modelId = 1; // 模型 ID modelTexturesId = 53; // 材质 ID }
The text was updated successfully, but these errors were encountered:
Fix: Fix the check of invalid model id
6dd81e1
Fix the issue of stevenjoezhang#182
Add/Fix: Add JSDoc for function and type and fix bugs (#175)
689b5c4
* Fix the missing initWidget See #176 * Fix the check of invalid model id See #182 --------- Co-authored-by: Mimi <[email protected]>
谢谢反馈,已在 #175 中修复,感谢 @whats2000 如果问题仍然存在,欢迎继续回复
Sorry, something went wrong.
No branches or pull requests
158行 左右的初始化函数中,会先从 localStorage 中读取
modelId
,并将其转换为数字类型(number | null)
。但如果localStorage.getItem('modelId')
返回的是null
(即该键不存在),似乎仍然会把它转换成 Number,导致结果会是NaN
而不是null
。这就会导致 162行 的
if (modelId === null)
判断出错。我的解决方法是直接去掉
=== null
,改为直接判断modelId
变量的值是否为假值。原始代码:
修改后:
The text was updated successfully, but these errors were encountered: