首页 > 其他分享 >Require.js中shim的用法

Require.js中shim的用法

时间:2022-12-02 10:24:37浏览次数:37  
标签:jquery bootstrapTable shim Require js test require

普通js文件加载

 

//test.js
function test() {  
}

//配置
require.config({
    paths: {
        test: 'lib/shim/test'
    },
    shim: {
         test: {
            exports: 'test'
        }
    }
});

//调用
require(['test'], function(test) {
    console.log(test);
});

jquery插件加载

//配置
require.config({
    paths: {
        jquery: 'lib/jquery-2.1.1.min',
        'jquery.bootstrapTable': 'lib/shim/bootstrap-table'
    },
    shim: {
         'jquery.bootstrapTable':  ['jquery'] //依赖jquery
         /* 或者
         'jquery.bootstrapTable': {
            deps: ['jquery'],
            exports: 'jQuery.fn.bootstrapTable'
         }
         */
    }
});

//调用
require(['jquery.bootstrapTable'], function() {
	console.log($('div').bootstrapTable);
});

  

标签:jquery,bootstrapTable,shim,Require,js,test,require
From: https://www.cnblogs.com/tomcat2022/p/16943592.html

相关文章

  • 模块化开发RequireJS之shim配置
    模块化开发RequireJS之shim配置weixin_33971130于 2017-12-0711:31:00 发布185 收藏 1文章标签: javascript ViewUI 一、shimrequirejs使用AMD......
  • js- day03- 将数据变成柱形图
    柱形图的渲染*{      margin:0;      padding:0;    } .box{      display:flex;      width:7......
  • python生成requirements.txt文件
     使用步骤: 1、先安装pipreqs库pipinstallpipreqs2、在当前目录使用生成pipreqs./--encoding=utf8--force            --encoding=utf8:......
  • js-day01-商品订单信息
    学会表格表单(html+css)表格的默认CSS属性*{      margin:0;      padding:0;    }    table{      margi......
  • react JSX
    JSX到底是什么?一种标签语法,hs进行的语法拓展不是字符串,不是HTML标签描述UI呈现与交互的直观的形式生成react元素createElement与jsx对比constrE1=<h1>Thisi......
  • Next.js & styled-components All In One
    Next.js&styled-componentsAllInOnestyled-components$npmi-Sstyled-components$yarnaddstyled-componentshttps://styled-components.com/https://gi......
  • vercel deploy next.js error All In One
    verceldeploynext.jserrorAllInOnehttps://vercel.com/web-full-stack/nextjs-ssr/deploymentsbug[23:57:30.114]Cloninggithub.com/web-full-stack/nextjs-ss......
  • js-day02-综合案例ATM存款书写
     <script>        //1.不断的弹出对话框    //3.金额的变量    letmoney=100    while(true){     ......
  • js day04 实参与形参个数不一致
    //functionfn(x,y){    //  //x=1    //  //y=undefined    //  //1+undefined = NaN    //  ......
  • for in 和 for of 是js中常用的遍历方法。但是两者有什么区别呢?
    forin和forof是js中常用的遍历方法。但是两者有什么区别呢?今天我们就来讨论下两者的区别。遍历数组forin是ES5的语法标准,而forof则是ES6语法标准。const......