首页 > 解决方案 > attr("disabled", false) 在 Typescript 中导致错误

问题描述

我的 ts 文件中有以下代码:

 $('input[type=hidden]').attr("disabled", false);

代码有效,但我收到以下错误:“假”类型的参数不可分配给“字符串”类型的参数 | 号码 | (((this: HTMLElement, index: number, attr: string) => string | number | void)'。

标签: javascripttypescriptinputdisabled-input

解决方案


您应该完全删除属性。

 $('input[type=hidden]').removeAttr("disabled");

推荐阅读