jq封装方法步骤

例子如下:

(function($) { var compiled = {}; $.fn.handlebars = function(template, data) { if (template instanceof jQuery) { template = $(template).html(); } compiled[template] = Handlebars.compile(template); this.html(compiled[template](data)); }; })(jQuery); $('#content').handlebars($('#template'), { name: "Alan" });
posted on 2016-12-03 22:23  1883808  阅读(367)  评论(0编辑  收藏  举报