export default class Model3 { constructor() { } static get instance() { if (!Model3._instance) { Object.defineProperty(Model3, "_instance", { value: new Model3() }); } return Model3._instance; } }
export default (function(){ var _instance; return class Model1{ static getInstance(){ if(!_instance) _instance = new Model1(); return _instance; } } })();
原文:https://www.cnblogs.com/ltfxy/p/12339861.html