jQuery技术:数据表Bootstrap主题在使用ReactJS时不适用

我是RequireJS的新手,所以请保持温柔!

下面是我的HTML和JS的链接,如果你运行它,你会看到数据表已正确初始化,但它没有应用bootstrap主题。

链接问题:

https://jsfiddle.net/sajjansarkar/c2f7s2jz/2/

我究竟做错了什么?

下面是我的JS(如果小提琴不起作用):

requirejs.config({ paths: { 'jquery': 'https://ajax.googleapis.com/ajax/libs/jquery/1.12.3/jquery', 'bootstrap': 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min', 'datatables': 'https://cdn.datatables.net/v/bs/dt-1.10.12/b-1.2.2/b-colvis-1.2.2/b-html5-1.2.2/cr-1.3.2/fh-3.1.2/kt-2.1.3/r-2.1.0/sc-1.4.2/se-1.2.0/datatables.min', }, shim: { 'bootstrap': { deps: ['jquery'] }, 'datatables': ['jquery', 'bootstrap'], } }); require([ 'jquery', 'bootstrap', , 'datatables' ], function($, Bootstrap, datatables) { 'use strict'; $('#example').dataTable(); }); 

HTML:

        ... 
Name Position Office Age Start date Salary
Tiger Nixon System Architect Edinburgh 61 2011/04/25 $320,800

    你要做的事情有很多问题:

    如果我将JavaScript修改为此,我会得到正确的结果:

     requirejs.config({ paths: { 'jquery': 'https://ajax.googleapis.com/ajax/libs/jquery/1.12.3/jquery', 'bootstrap': 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min', 'datatables': 'https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min', 'datatables.bootstrap': 'https://cdn.datatables.net/1.10.15/js/dataTables.bootstrap.min', }, shim: { 'bootstrap': { deps: ['jquery'] }, }, map: { '*': { 'datatables.net': 'datatables', } }, }); require(['jquery', 'datatables.bootstrap'], function($) { 'use strict'; $('#example').dataTable(); }); 

    这是一个分叉的小提琴 。

      以上就是jQuery教程分享数据表Bootstrap主题在使用ReactJS时不适用相关内容,想了解更多jQuery开发(异常处理)及jQuery教程关注计算机技术网(www.ctvol.com)!)。

      本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

      ctvol管理联系方式QQ:251552304

      本文章地址:https://www.ctvol.com/jquerytutorial/573516.html

      (0)
      上一篇 2021年3月7日
      下一篇 2021年3月7日

      精彩推荐