Ionic 3 - Typescript 错误:算术操作数的类型必须是“any”、“number”或枚举类型

亚历克斯200

当用户单击类似按钮以增加数字时,我有一个单击操作,但是在构建或运行 ionic 应用程序时,我有一个打字稿错误,有人可以帮我解决这个问题吗?

Typescript Error
An arithmetic operand must be of type 'any', 'number' or an enum type.
src/pages/comments/comments.ts
document.getElementById("like-" + commentid).innerHTML++

在comments.ts

likedislike(type,commentid) {
  if(type === 'like') {
    document.getElementById("like-" + commentid).innerHTML++
  }
}
罗布雷希特VM

尝试使用Number()将内部 html 字符串转换为数字。

var x = document.getElementById("like-" + commentid).innerHTML; 

document.getElementById("like-" + commentid).innerHTML = Number(x) + 1

尽管在 Ionic 中使用 Angular 数据绑定来做到这一点更好......

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

TypeScript泛型错误:算术运算的左侧必须为“ any”,“ number”,“ bigint”类型

Ionic 2语法错误,而编译TypeScript

TypeScript 3:类型中缺少属性

ionic modal获取错误以打开:ionic 3

*:Python 3中不支持*:'NoneType'和'int'的操作数类型

Ionic 3 FormControl错误不显示

错误:“ operator *”不匹配(操作数类型为“ QGenericMatrix <4,4,float>”和“ QGenericMatrix <4,3,float>”)

Typescript 3和数组类型节点

Python3:+不支持的操作数类型:“ float”和“ str”

算术操作数类型转换

Python中带有SQLite3 Type的参数出错错误:+不支持的操作数类型:'sqlite3.Cursor'和'str'

错误的操作数类型

错误的操作数类型

Python3:socket:TypeError:%不支持的操作数类型:“字节”和“字节”

Python 3:/:“ float”和“ bytes”不受支持的操作数类型

操作数类型错误

TypeError:+ =:Python 3中不支持的操作数类型为“ float”和“ NoneType”

Angular 2 / Ionic 2中的Typescript转换错误

Python 3 TypeError:**或pow()不支持的操作数类型:“ str”和“ int”

Python 3.x 不支持使用编码解码的操作数类型

JSON 解析中的 Ionic 3 错误

得到错误算术运算的左侧必须是“any”、“number”或枚举类型

Ionic 3 Firebase 登录因错误而停止

Ionic 3 TypeScript 错误 - 类型“void”上不存在属性“then”

如何在 Ionic3 和 Typescript 中使用 EmojiOne?

错误 TS2356 表示数字类型变量必须是“数字”类型的算术操作数

Python 3:不支持的操作数类型 -:'str' 和 'float'

Python 3:类型错误:+ 不支持的操作数类型:'float' 和 'str'

算术操作数必须是“any”、“number”、“bigint”或枚举类型。ts(2356)