We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
问题描述 使用Symbol的时候遇到一个诡异的问题。 问题描述图片:
// constant export const MODE = { VIEW: Symbol('VIEW'), SELECT_GROUP: Symbol('SELECT_GROUP'), SELECT_ROUTINE: Symbol('SELECT_ROUTINE') } // default mode is Symbol('VIEW') ... const { exercisesStore: { exercises, mode } } = this.props console.log('---', mode, MODE.SELECT_ROUTINE === mode) // 输出: false ... // 组件会被显示出来,但是仅仅是显示,props没有传进去 // 可以看到上面图片组件的count是0,而且dispatchDone不会触发 {mode === MODE.SELECT_ROUTINE && ( <SelectedPanel dispatchDone={this.handleSelectedDone} count={1} /> )}
而且Mobx中改变属性的Symbol值,会报警告:
// mobx state mode: MODE.VIEW, // mobx function changeState(mode) { console.log(mode) if (MODE.VIEW === mode) { this.mode = MODE.VIEW } if (MODE.SELECT_GROUP === mode) { this.mode = MODE.SELECT_GROUP } if (MODE.SELECT_ROUTINE === mode) { this.mode = MODE.SELECT_ROUTINE } },
但是不使用Symbol时,就正常:
export const MODE = { VIEW: 'VIEW', SELECT_GROUP: 'SELECT_GROUP', SELECT_ROUTINE: 'SELECT_ROUTINE' }
复现步骤 [复现问题的步骤]
// 问题代码 export const MODE = { VIEW: Symbol('VIEW'), SELECT_GROUP: Symbol('SELECT_GROUP'), SELECT_ROUTINE: Symbol('SELECT_ROUTINE') } // 正常 export const MODE = { VIEW: 'VIEW', SELECT_GROUP: 'SELECT_GROUP', SELECT_ROUTINE: 'SELECT_ROUTINE' }
判断行为确实可以正常判断,但是组件内部显示不正常。
期望行为 期望使用Symbol应该有使用字符串一样的期望
报错信息
没有报错信息,只有诡异的期望
系统信息
Taro v1.2 及以上版本已添加 taro info 命令,方便大家查看系统及依赖信息,运行该命令后将结果贴下面即可。
taro info
补充信息
"dependencies": { "@antv/f2": "^3.3.9", "@tarojs/async-await": "^1.3.4", "@tarojs/components": "1.3.4", "@tarojs/mobx": "1.3.4", "@tarojs/mobx-h5": "1.3.4", "@tarojs/mobx-rn": "1.3.4", "@tarojs/rn-runner": "1.3.4", "@tarojs/router": "1.3.4", "@tarojs/taro": "1.3.4", "@tarojs/taro-alipay": "1.3.4", "@tarojs/taro-h5": "1.3.4", "@tarojs/taro-swan": "1.3.4", "@tarojs/taro-tt": "1.3.4", "@tarojs/taro-weapp": "1.3.4", "mobx": "4.8.0", "nerv-devtools": "^1.4.3", "nervjs": "^1.4.3", "prop-types": "^15.7.2", "taro-f2": "^2.1.2", "taro-ui": "^2.2.0" },
还不是很清楚这个问题出在哪里
The text was updated successfully, but these errors were encountered:
欢迎提交 Issue~
如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏
如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。
Good luck and happy coding~
Sorry, something went wrong.
Symbol 应该不能直接使用,需要加 polyfill
好的,感谢答复
No branches or pull requests
问题描述
使用Symbol的时候遇到一个诡异的问题。
问题描述图片:
而且Mobx中改变属性的Symbol值,会报警告:
但是不使用Symbol时,就正常:
复现步骤
[复现问题的步骤]
判断行为确实可以正常判断,但是组件内部显示不正常。
期望行为
期望使用Symbol应该有使用字符串一样的期望
报错信息
没有报错信息,只有诡异的期望
系统信息
补充信息
还不是很清楚这个问题出在哪里
The text was updated successfully, but these errors were encountered: