14--jQuery插件大全-- bootstrapTable 表单神器

本文详细介绍bootstrapTable插件的使用方法,包括如何渲染静态数据和从URL加载JSON数据,为前端开发者提供实用的代码示例。

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

目录

bootstrapTable 表单神器 

1、静态数据渲染 

 在table标签中设置代码如下:

 2、数据来自url

json数据渲染代码如下:

 table.json数据


bootstrapTable 表单神器 

      -官网[https://bootstrap-table.com/](https://bootstrap-table.com/)
       -github[https://github.com/wenzhixin/bootstrap-table.git](https://github.com/wenzhixin/bootstrap-table.git)  

1、静态数据渲染 

 在table标签中设置代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>bootstrapTable</title>
    <link rel="stylesheet" href="../css/bootstrap3/css/bootstrap.min.css">
    <link rel="stylesheet" href="../css/bootstrap-table/css/bootstrap-table.min.css">
    <script src="../js/jquery-3.3.1.min.js"></script>
    <script src="../js/bootstrap3/js/bootstrap.min.js"></script>
    <script src="../js/bootstrap-table/js/bootstrap-table.min.js"></script>
    <script src="../js/bootstrap-table/js/bootstrap-table-zh-CN.js"></script>
</head>
<body>
<div class="container">
    <div class="bootstrap-table">
    <table  data-toggle="table" data-search="true" data-show-columns="true" data-show-refresh="true" data-show-toggle="true">
        <thead>
        <tr>
            <th>姓名</th>
            <th>年龄</th>
            <th>住址</th>
        </tr>
        </thead>
        <tr>
            <td>刘亦菲</td>
            <td>32</td>
            <td>绝情谷</td>
        </tr>
        <tr>
            <td>李易峰</td>
            <td>30</td>
            <td>绝情谷</td>
        </tr>
        <tr>
            <td>李娜</td>
            <td>32</td>
            <td>武汉</td>
        </tr>
        <tr>
            <td>岳云鹏</td>
            <td>35</td>
            <td>北京</td>
        </tr>
    </table>
    </div>
</div>
</body>
</html>

 2、数据来自url

json数据渲染代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>bootstrapTable</title>
    <link rel="stylesheet" href="../css/bootstrap3/css/bootstrap.min.css">
    <link rel="stylesheet" href="../css/bootstrap-table/css/bootstrap-table.min.css">
    <script src="../js/jquery-3.3.1.min.js"></script>
    <script src="../js/bootstrap3/js/bootstrap.min.js"></script>
    <script src="../js/bootstrap-table/js/bootstrap-table.min.js"></script>
    <script src="../js/bootstrap-table/js/bootstrap-table-zh-CN.js"></script>
</head>
<body>
<div class="container">
    <div class="bootstrap-table">
    <table  data-toggle="table" data-search="true" data-show-columns="true" data-pagination-loop="false" data-page-list=[5,10,15] data-pagination="true" data-url="../js/bootstrap-table/table.json" data-show-refresh="true" data-show-toggle="true">
        <thead>
        <tr>
            <th data-field="id">ID</th>
            <th data-field="name">名称</th>
            <th data-field="price">价格</th>
            <th data-field="amount">总数</th>
        </tr>
        </thead>

    </table>
    </div>
</div>
</body>
</html>

 table.json数据

[
  {
    "id": 0,
    "name": "Item 0",
    "price": "$0",
    "amount": 3
  },
  {
    "id": 1,
    "name": "Item 1",
    "price": "$1",
    "amount": 4
  },
  {
    "id": 2,
    "name": "Item 2",
    "price": "$2",
    "amount": 8
  },
  {
    "id": 3,
    "name": "Item 3",
    "price": "$3",
    "amount": 2
  },
  {
    "id": 4,
    "name": "Item 4",
    "price": "$4",
    "amount": 90
  },
  {
    "id": 5,
    "name": "Item 5",
    "price": "$5",
    "amount": 2
  },
  {
    "id": 6,
    "name": "Item 6",
    "price": "$6",
    "amount": 3
  },
  {
    "id": 7,
    "name": "Item 7",
    "price": "$7",
    "amount": 7
  },
  {
    "id": 8,
    "name": "Item 8",
    "price": "$8",
    "amount": 39
  },
  {
    "id": 9,
    "name": "Item 9",
    "price": "$9",
    "amount": 78
  },
  {
    "id": 10,
    "name": "Item 10",
    "price": "$10",
    "amount": 30
  },
  {
    "id": 11,
    "name": "Item 11",
    "price": "$11",
    "amount": 32
  },
  {
    "id": 12,
    "name": "Item 12",
    "price": "$12",
    "amount": 12
  },
  {
    "id": 13,
    "name": "Item 13",
    "price": "$13",
    "amount": 76
  },
  {
    "id": 14,
    "name": "Item 14",
    "price": "$14",
    "amount": 10
  },
  {
    "id": 15,
    "name": "Item 15",
    "price": "$15",
    "amount": 9
  },
  {
    "id": 16,
    "name": "Item 16",
    "price": "$16",
    "amount": 8
  },
  {
    "id": 17,
    "name": "Item 17",
    "price": "$17",
    "amount": 1
  },
  {
    "id": 18,
    "name": "Item 18",
    "price": "$18",
    "amount": 99
  },
  {
    "id": 19,
    "name": "Item 19",
    "price": "$19",
    "amount": 100
  },
  {
    "id": 20,
    "name": "Item 20",
    "price": "$20",
    "amount": 109
  }
]

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值