设计模式-适配器模式

        class GlobalStandard {
            GlobalVoltage(){
                return '全球标准电压330V'
            }
        }

        class ChinaStandard {
            constructor(){
                this.globalstandard = new GlobalStandard()
            }
            ChinaVoltage(){
                let standard = this.globalstandard.GlobalVoltage()
                return `${standard} - 转换器 --中国标准电压220V`
            }
        }

        //测试
        let target = new ChinaStandard()
        let res = target.ChinaVoltage()
        console.log(res)// 全球标准电压330V - 转换器 --中国标准电压220V
原文地址:https://www.cnblogs.com/yzyh/p/10305972.html