Typescript常见语法错误

  • Property 'attachEvent' does not exist on type 'Window' 

(window).attachEvent("onmessage", callback);

 

  • does not exist on type of GlobalEventHandlers
const el: HTMLElement | null = document.querySelector('xxx');
  • Parameter 'el' implicitly has an 'any' type.
    //Parameter 'el' implicitly has an 'any' type.
    const parentKey = root.find(el => el === node).parent;
    //修改为:
    const parentKey = root.find((el:any) => el === node).parent;
    
    

     

  • Property 'name' has no initializer and is not definitely assigned in the constructor.

    name!:string;    //使用这种定义方式,而不采用 name:string

 

你可能感兴趣的:(vue,vue.js,typescript)