cmd -模块化

来源:互联网 发布:围巾淘宝店推荐知乎 编辑:程序博客网 时间:2024/05/16 14:20

html:配置和使用

seajs.config({
alias:{
'jq' : 'jquery-1.12.1.js'
}
})

seajs.use(['./js/computer'],function(a){
a.say();
})


js中模块化

define(function(require, exports,module){
require('jq');
exports.say = function(){
console.log($)
// $('#foot').append('<li>sade</li>')
$.ajax({
type:"get",
url:"data/1.json",
async:true,
success:function(e){
console.log(e);
for (var i = 0; i < e.shop_data.length; i++) {
// e.shop_data[i]
$('#foot').append('<li><img / ><p></p><p></p></li>');
$('#foot').children().eq(i).find('img').attr({'src' : e.shop_data[i].shop_ico});
$('#foot').children().eq(i).find('p').eq(0).text(e.shop_data[i].shop_name);
$('#foot').children().eq(i).find('p').eq(1).text(e.shop_data[i].shop_desc);
}

}
});
}
})

文件在hbuilder打开

0 0
原创粉丝点击