requery.js 如何配置第三方库?

博客展示了RequireJS的配置代码,包括基础路径和模块路径的设置,涵盖第三方模块如jQuery、Bootstrap,自定义模块、HTML和CSS。还给出了使用require函数加载模块的示例,体现了前端开发中模块化管理的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

require.config({
baseUrl: ‘./js’,
paths: {
// 第三方模块
‘jquery’: ‘lib/jquery-3.3.1’,
‘text’: “lib/text”,
‘css’: ‘lib/css’,
‘css’: ‘lib/css’,
‘bootStrap’: ‘lib/bootstrap-3.3.7/bootstrap’,
‘bootstrap_css’: “lib/bootstrap-3.3.7/bootstrap”,
// 自定义模块
‘person’: ‘person’,
// 自定义html
‘personPage’: ‘…/pages/person.html’,
‘tabNav’: ‘…/pages/tabNav.html’,
// 自定义CSS
‘indexStyle’: ‘…/css/index’

},
shim: { // 配置第三方不支持AMD 格式的库或者插件
    'bootStrap': {
        deps: ['jquery'], // 注入bootstap 需要依赖的模块
        exports: 'bootStrap',
      
    }
},

})

require([‘jquery’, ‘person’, ‘text!personPage’, ‘text!tabNav’, ‘bootStrap’,‘css!indexStyle’], function ($, person, template1, template2) {

console.log(template2)
$('#main').html(template2)

})

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值