ts refers to window custom variable or value data type error solution
Some methods or objects under the window will report errors when used directly. The general solution is as follows:
1. Use interface to define type
interface WindowType {
xxx: string;
}
2. Use type to define the type
type WindowType = {
xxx: string;
}
3. Use as to cast the type to any
(window as any).xxx
4. Use square brackets when calling to get
window['xxx']
Almost these are the most commonly used solutions, please leave a message if you have any questions