Created
October 18, 2019 10:09
-
-
Save imapolaris/1f02a75d95af9b32367fae5056aa9ac7 to your computer and use it in GitHub Desktop.
create a singleton
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// file a | |
class A { | |
welcome(name) { | |
console.log('welcome, ', name) | |
} | |
} | |
export let AIns = new A() | |
import {Ains} from './a' | |
// 基于模块的特性,创建一个单例对象 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment