判断字符串
判断字符串可用“==”和“equals”
提示:注意equals用不了string类型的字符串
原因
equals(other: StyledString): boolean;
equals对对象StyledString才有效果
例如:
class MutableStyledString extends StyledString
MutableStyledString 继承于 StyledString ,所有这个字符串对象才有equals 方法
使用“==”
这个的话就可以直接比较两个string类型的数据
但是:如果这样写就不行
这里的意思其实就是说 这很明显不相等 ,所以就报错
不过你可以这样写
txt : string = "22"
if ("11"==this.txt) {
}
这样就可以了