Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
357 views
in Technique[技术] by (71.8m points)

Typescript Type 'number' is not assignable to type 'string' // Argument of type 'HTMLInputElement' is not assignable to parameter of type 'string'

function Sum() {
    var Number1 = 0, Number2 = 0, sum = 0;
    var input: HTMLInputElement;
    input = <HTMLInputElement>document.getElementById("txtNumber1");
    Number1 = parseFloat(input);
    input = <HTMLInputElement>document.getElementById("textNumber2");
    Number2 = parseFloat(input);
    sum = Number1 + Number2;
    var txtNumberSum: HTMLParagraphElement;
    var txtNumberSum = <HTMLParagraphElement>document.getElementById("txtNumberSum");
    txtNumberSum.innerHTML = sum;
}

TypeScipt Code

Error code's Argument of type 'HTMLInputElement' is not assignable to parameter of type 'string'

Type 'number' is not assignable to type 'string

html Code

question from:https://stackoverflow.com/questions/65830611/typescript-type-number-is-not-assignable-to-type-string-argument-of-type

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...