Skip to content

Instantly share code, notes, and snippets.

@imapolaris
Created October 18, 2019 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imapolaris/1f02a75d95af9b32367fae5056aa9ac7 to your computer and use it in GitHub Desktop.
Save imapolaris/1f02a75d95af9b32367fae5056aa9ac7 to your computer and use it in GitHub Desktop.
create a singleton
// 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