Why? Yes, the TS compiler diagnosed document at compile time Getelementbyid (‘test ‘) may be null, so a prompt is given: the object may be null. The solution is as follows:
document.getElementById('test')!.innerHTML = greeter(user);
Add one!, What does the exclamation point mean?It is actually a not null assertion operator. It does not perform runtime check and tells the compiler that it only needs to know this thing
Similar Posts:
- How to Solve Error: Cannot set property ‘onclick’ of null
- JavaScript Uncaught TypeError: Cannot set property ‘innerHTML’ of null”
- An error occurs when angular uses canvas
- Syntax error reported by JavaScript function: expected expression, got ‘;’
- ”Cannot read property ‘addEventListener’ of null“
- Interaction between web browser and JavaScript in WPF
- [Solved] Operator overload must take either zero or one argument error
- How to Solve Request processing failed; nested exception is java.lang.NullPointerException
- error: ‘to_string’ was not declared in this scope
- Vs generation fails without error [How to Solve]