首页 > 其他 > 详细

组件方式开发实例

时间:2016-12-04 23:02:44      阅读:267      评论:0      收藏:0      [点我收藏+]



/* 基本图文组件对象 */
var H5ComponentBase =function ( name, cfg ) {
var cfg = cfg || {};
var id = ( ‘h5_c_‘+Math.random() ).replace(‘.‘,‘_‘) ;
// 把当前的组建类型添加到样式中进行标记
var cls = ‘ h5_component_‘+cfg.type;
var component = $(‘
‘); cfg.text && component.text(cfg.text); cfg.width && component.width(cfg.width/2); cfg.height && component.height(cfg.height/2); cfg.css && component.css( cfg.css ); cfg.bg && component.css(‘backgroundImage‘,‘url(‘+cfg.bg+‘)‘); if( cfg.center === true){ component.css({ marginLeft : ( cfg.width/4 * -1) + ‘px‘, left:‘50%‘ }) } // ... 很多自定义的参数 if( typeof cfg.onclick === ‘function‘ ){ component.on(‘click‘,cfg.onclick); } return component; }

组件方式开发实例

原文:http://www.cnblogs.com/heyinwangchuan/p/6132207.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!