[Vue warn]: Property or method “window“ is not defined on the instance but referenced during render.

不要把自己的东西挂到全局上

类型声明:global.d.ts

import Vue from 'vue'

declare module 'vue/types/vue' {
  interface Vue {
    $message: any
  }
}

declare global {
  interface Window {
    $message: any
    Beidou: any
    uploadType:string
  }
}

原因:示例 this.

html标签中查找的变量都是通过vue实例,即this.调用,而找不到全局的window

解决:赋给示例/computed再用

global.d.ts | Chaoszhu's Blog

猜你喜欢

转载自blog.csdn.net/qq_28838891/article/details/132171492