提交 df5cb8af 编写于 作者: H hdx

call-method:移除 不必要的非空判定

上级 78dd38eb
......@@ -38,11 +38,11 @@
},
callMethod5() {
// 注意: 返回值可能为 null,当前例子一定不为空,所以加了 !
const result = this.$callEasyMethod1!.foo5('string1')! as string;
const result = this.$callEasyMethod1!.foo5('string1') as string;
console.log(result); // string1
},
callMethodTest(text: string): string | null {
const result = this.$callEasyMethod1!.foo5(text)! as string;
const result = this.$callEasyMethod1!.foo5(text) as string;
return result;
},
callMethodInOtherFile(text: string): string {
......
......@@ -36,11 +36,11 @@
},
callMethod5() {
// 注意: 返回值可能为 null,当前例子一定不为空,所以加了 !
const result = this.$callEasyMethod1!.foo5('string1')! as string;
const result = this.$callEasyMethod1!.foo5('string1') as string;
console.log(result); // string1
},
callMethodTest(text: string): string | null {
const result = this.$callEasyMethod1!.foo5(text)! as string;
const result = this.$callEasyMethod1!.foo5(text) as string;
return result;
},
}
......
......@@ -46,11 +46,11 @@
callMethod5() {
// 通过 $callMethod 调用组件的 foo5 方法并接收返回值
// 注意: 返回值可能为 null,当前例子一定不为空,所以加了 !
const result = this.$component1!.$callMethod('foo5', 'string1')! as string;
const result = this.$component1!.$callMethod('foo5', 'string1') as string;
console.log(result); // string1
},
callMethodTest(text: string): string | null {
const result = this.$component1!.$callMethod('foo5', text)! as string;
const result = this.$component1!.$callMethod('foo5', text) as string;
return result;
},
}
......
......@@ -23,7 +23,7 @@
},
callMethodTest(text: string): string | null {
this.$slider1!.setAttribute('value', text);
const result = this.$slider1!.getAttribute('value')! as string;
const result = this.$slider1!.getAttribute('value') as string;
return result;
},
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册