doubleyong
管理员
管理员
  • 最后登录2024-04-24
  • 发帖数1167
  • 最爱沙发
  • 喜欢达人
  • 原创写手
  • 社区居民
  • 忠实会员
阅读:1719回复:0

[typescript]error: The left-hand side of an assignment expression may not be an optional property access.

楼主#
更多 发布于:2023-09-19 14:26
错误:
    The left-hand side of an assignment expression may not be an optional property access.


代码:

businessName.value = null;
counselorName.value = null;
resInfName.value = null;


解决方案:

使用类型断言, 把null 和 undefined的值都排除掉, 代码如下:
businessName!.value = null;
counselorName!.value = null;
resInfName!.value = null;
知识需要管理,知识需要分享
游客


返回顶部

公众号

公众号