直接获取报错:
let el = document.getElementById(getActivity('console-ipt'));
let val = el.value;
error:TS2339: Property 'value' does not exist on type 'HTMLElement'.
网上查询的方法:
//第一种方法
let el = <HTMLInputElement>document.getElementById(getActivity('console-ipt'));
let val = el.value;
//第二种方法
let el = document.getElementById(getActivity('console-ipt')) as HTMLInputElement;
let val = el.value;
官方教程文章:
image.png
网友评论