[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

你可能感兴趣的:(前端,bug,vue.js,javascript,前端)