跳转到内容

vue全局属性

使用方法

(main.ts)中定义

import * as THREE from 'three'

app.config.globalProperties.$THREE = THREE

局部组件中使用

import { getCurrentInstance } from 'vue'

// 获取当前实例
const app = getCurrentInstance()

// 通过 app 访问全局属性
const THREE = app?.appContext.config.globalProperties.$THREE