首页 > web前端 > Bootstrap教程 > bootstrap table 怎么绑定数据

bootstrap table 怎么绑定数据

(*-*)浩
发布: 2019-07-11 09:27:11
原创
4013 人浏览过

支持三种方式bootstrap table绑定数据:1.html格式数据(即静态数据);2.JavaScript传递数据;3.数据属性变量动态获取。

bootstrap table 怎么绑定数据

静态表格:data-toggle="table"(推荐学习:Bootstrap视频教程

<table data-toggle="table">
  <thead>
    <tr>
      <th>Item ID</th>
      <th>Item Name</th>
      <th>Item Price</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>1</td>
      <td>Item 1</td>
      <td>$1</td>
    </tr>
    <tr>
      <td>2</td>
      <td>Item 2</td>
      <td>$2</td>
    </tr>
  </tbody>
</table>
登录后复制

JavaScript方式

<table id="table"></table>
<!--定义一个表格,无需设置表头,统一在JS中初始化,灵活度较高(梁新建议)-->
<script>
$('#table').bootstrapTable({
  url: 'data1.json',
  pagination: true,
  search: true
  columns: [{
    field: 'id',
    title: 'Item ID'
  }, {
    field: 'name',
    title: 'Item Name'
  }, {
    field: 'price',
    title: 'Item Price'
  }, ]
})
</script>
登录后复制

数据属性变量动态获取

<table
  data-toggle="table"
  data-url="data1.json"
  data-pagination="true"
  data-search="true">
  <thead>
    <tr>
      <th data-sortable="true" data-field="id">Item ID</th>
      <th data-field="name">Item Name</th>
      <th data-field="price">Item Price</th>
    </tr>
  </thead>
</table>
登录后复制

更多Bootstrap相关技术文章,请访问Bootstrap教程栏目进行学习!

以上是bootstrap table 怎么绑定数据的详细内容。更多信息请关注PHP中文网其他相关文章!

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
最新问题
没有bootstrap自定义的视频教程
来自于 1970-01-01 08:00:00
0
0
0
引入bootstrap无效
来自于 1970-01-01 08:00:00
0
0
0
angular.js - angular对于ui-bootstrap的使用
来自于 1970-01-01 08:00:00
0
0
0
html5 - bootstrap修改样式的问题
来自于 1970-01-01 08:00:00
0
0
0
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板