码迷,mamicode.com
首页 > 其他好文 > 详细

组件方式开发实例

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

标签:color   com   组件   end   ase   配置文件   ima   math   eof   




/* 基本图文组件对象 */
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; }

组件方式开发实例

标签:color   com   组件   end   ase   配置文件   ima   math   eof   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!