最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

bootstrap-table formatter 使用vue组件的方法

来源:动视网 责编:小采 时间:2020-11-27 21:57:19
文档

bootstrap-table formatter 使用vue组件的方法

bootstrap-table formatter 使用vue组件的方法:bootstrap-table简介 •1.1、bootstrap table简介及特征: Bootstrap table是国人开发的一款基于 Bootstrap 的 jQuery 表格插件,通过简单的设置,就可以拥有强大的单选、多选、排序、分页,以及编辑、导出、过滤(扩展)等等的功能。目前在githu
推荐度:
导读bootstrap-table formatter 使用vue组件的方法:bootstrap-table简介 •1.1、bootstrap table简介及特征: Bootstrap table是国人开发的一款基于 Bootstrap 的 jQuery 表格插件,通过简单的设置,就可以拥有强大的单选、多选、排序、分页,以及编辑、导出、过滤(扩展)等等的功能。目前在githu


bootstrap-table简介

•1.1、bootstrap table简介及特征:

         Bootstrap table是国人开发的一款基于 Bootstrap 的 jQuery 表格插件,通过简单的设置,就可以拥有强大的单选、多选、排序、分页,以及编辑、导出、过滤(扩展)等等的功能。目前在github上已经有2600多个Star,可见其受欢迎程度。其官方网站地址 为:http://bootstrap-table.wenzhixin.net.cn/。里面可以下载使用所需的JS和CSS文件,以及参考文档和例子。

•支持 Bootstrap 3 和 Bootstrap 2
•自适应界面
•固定表头
•非常丰富的配置参数
•直接通过标签使用
•显示/隐藏列
•显示/隐藏表头
•通过 AJAX 获取 JSON 格式的数据
•支持排序
•格式化表格
•支持单选或者多选
•强大的分页功能
•支持卡片视图
•支持多语言
•支持插件

下面通过实例代码给大家介绍bootstrap-table formatter 使用vue组件的方法,具体代码如下所示:

import { Subject } from "rxjs";
import Vue from "vue";
export const BtEventHub = new Subject();
const VueComList = [];
let VueComId = 0;
BtEventHub.debounceTime(10)
 .filter(() => VueComList.length > 0)
 .delay(10)
 .subscribe(function() {
 const len = VueComList.length - 1;
 for (let i = len; i >= 0; i--) {
 const item = VueComList[i];
 const dom = document.getElementById(item.name);
 if (dom != null) {
 new Vue(item);
 VueComList.splice(i, 1);
 }
 }
 if (VueComList.length === 0) {
 VueComId = 0;
 }
 });
export function BtAddVueCom(obj: object) {
 const id = `_vue_com_${VueComId++}`;
 VueComList.push({
 el: "#" + id,
 name: id,
 ...obj
 });
 setTimeout(() => {
 BtEventHub.next();
 }, 0);
 return id;
}
window["BtAddVueCom"] = BtAddVueCom;
function ColFormatter1(value, row) {
 const id = window.BtAddVueCom({
 template: '<el-switch v-model="row.IsShow"></el-switch>',
 data: function () {
 return {
 row
 }
 }
 });
 return `<div id="${id}"></div>`;
}

ps:Vue 结合bootstrap table插件使用

bootstrap Table插件可以很方便的搜索排序,方便快捷,下面是结合vue的完整的例子。

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="utf-8">
 <title>Vue Bootstrap Table Demo</title>
 <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
 <link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css" rel="external nofollow" >
 <link rel="stylesheet" href="../plugins/bootstrap-table-develop/src/bootstrap-table.css" rel="external nofollow" >
</head>
<body class="">
 <div>
 <table class="table table-bordered table-striped" id="tableTest1">
 </table>
 </div>
 <script src="../jQuery/jQuery-2.1.4.min.js"></script>
 <script src="../dist/vue.js"></script>
 <script src="../plugins/bootstrap-table-develop/src/bootstrap-table.js"></script>
 <script src="../plugins/bootstrap-table-develop/src/locale/bootstrap-table-zh-CN.js"></script>
 <script>
 var app7 = new Vue({
 el: '#tableTest1',
 data: {
 //message: [],
 message: [],
 columns: [{
 title: 'Id',
 field: 'id'
 },
 {
 field: 'name',
 title: 'Item Name'
 }, {
 field: 'url',
 title: 'url'
 }, {
 field: 'alex',
 title: 'alex'
 }, {
 field: 'country',
 title: 'country'
 }
 ],
 },
 created() {
 //console.log(this.message)
 this.getData();
 this.intervalGetData();
 //console.log(this.message)
 },
 methods: {
 intervalGetData() {
 setInterval(() => {
 // $.get("selectBtTable.php?action=init_data_list", data => {
 // var data = JSON.parse(data);
 // this.message = data;
 // $('#tableTest1').bootstrapTable('load', this.message);
 // //console.log(JSON.parse(data))
 // console.log("get data")
 // })
 this.getData();
 }, 3000)
 },
 getData() {
 //es6 箭头函数的写法
 // $.get("selectBtTable.php?action=init_data_list", data => {
 // var data = JSON.parse(data);
 // this.message = data;
 // $('#tableTest1').bootstrapTable('load', this.message);
 // console.log("init data")
 // })
 var that = this;
 $.get("selectBtTable.php?action=init_data_list", function(data) {
 var data = JSON.parse(data);
 that.message = data;
 $('#tableTest1').bootstrapTable('load', that.message);
 console.log("init data")
 })
 }
 },
 mounted() {
 console.log(this.message + "mounted")
 $('#tableTest1').bootstrapTable({ columns: this.columns, height: 500, search: true });
 }
 })
 </script>
</body>
</html>

     (adsbygoogle = window.adsbygoogle || []).push({}); 

总结

以上所述是小编给大家介绍的bootstrap-table formatter 使用vue组件的方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!

文档

bootstrap-table formatter 使用vue组件的方法

bootstrap-table formatter 使用vue组件的方法:bootstrap-table简介 •1.1、bootstrap table简介及特征: Bootstrap table是国人开发的一款基于 Bootstrap 的 jQuery 表格插件,通过简单的设置,就可以拥有强大的单选、多选、排序、分页,以及编辑、导出、过滤(扩展)等等的功能。目前在githu
推荐度:
标签: 使用 VUE table
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top