We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
模板方法模式是将一套逻辑的各个步骤都规定好,你只需要填写不同参数与回调函数体即可。
// 建立一个请求ajax并渲染数据的一个模板 var RenderDom = function (obj) { // 安全构造函数 if(!(this instanceof RenderDom)) { return new RenderDom(obj); } }; RenderDom.prototype.getData = function () { console.log('请求异步数据'); }; // 渲染模板生成html字符串 RenderDom.prototype.renderTemp = function () { console.error("还未确定渲染模板"); }; // 渲染模板 RenderDom.prototype.input = function () { console.error("还未确定填充对象"); }; RenderDom.prototype.init = function () { this.getData(); this.renderTemp(); this.input(); }; // 开始继承,这边就不再需要罗列初始化步骤 var F7Render = function (obj) {}; F7Render.prototype = new RenderDom(); F7Render.prototype.renderTemp = function() { console.log("div1") }; F7Render.prototype.input = function () { console.log("input2") }; var f7 = new F7Render(); f7.init();
The text was updated successfully, but these errors were encountered:
No branches or pull requests
模板方法模式使用
钩子方法的使用
The text was updated successfully, but these errors were encountered: