ts 单例模式

ts 单例模式

class AudioManage {
    static audio: AudioManage|null = null
    constructor(){
        console.log("constructor")
    }
    static Instance(){
        // Audio.audio = new Audio()
        if(AudioManage.audio == null){
            AudioManage.audio = new AudioManage();
        }
        return AudioManage.audio
    }
}

let audio = AudioManage.Instance()

  

posted on 2024-11-05 11:21  少杨  阅读(2)  评论(0编辑  收藏  举报