找回密码
 免费注册

[Bootstrap] bootstrap5搭配require.js使用jquery的实例

[复制链接]
admin 发表于 2023-3-25 21:17:31 | 显示全部楼层 |阅读模式
main.js
  1. require.config({
  2.     urlArgs: "debug=" + (new Date()).getTime(),
  3.     paths: {
  4.         'jquery': "../jquery/3.3.1/jquery.min",
  5.         'bootstrap': '../bootstrap/5.2.3/js/bootstrap.bundle.min'
  6.     },
  7.     shim:{
  8.         'bootstrap':{
  9.             exports: 'bootstrap'
  10.         }
  11.     }
  12. });
  13. //动态加载模块
  14. require(['index'], function(module){
  15.     console.log(module);
  16. }, function (e) {
  17.     console.error(e);
  18. });
复制代码
index.js
  1. define(['jquery','bootstrap'], function($,bootstrap){
  2.     $('#carousel').carousel({interval: 1000});
  3.     return true;
  4. });
复制代码


回复

使用道具 举报

 楼主| admin 发表于 2023-5-21 21:50:54 | 显示全部楼层
不引用其它JS的实例

  1. define(function(){
  2.     return true;
  3. });
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

QQ|Archiver|手机版|小黑屋|信息共享网

GMT+8, 2024-5-15 05:03 , Processed in 0.074982 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表