bootstrapTable使用场景及方式
场景一:混合开发,适用jsp、php前端不足 纯html结构
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | < div > < table id="table" data-toggle="table" data-url="http://guessulike.config.58v5.cn/gulrecomserviceweb/gulrecall/getscene" data-pagination="true" data-search="true" data-show-columns="true" data-show-refresh="true" data-show-toggle="true" data-page-number="1" data-page-size="15" data-sort-name="create_time" data-sort-order="desc" data-page-list="[10, 25, 50, 100, All]" data-click-to-select="true" data-single-select="true" data-toolbar="#toolbar"> < thead > < tr > < th data-field="state" data-checkbox="true"></ th > < th data-field="scene_name" data-switchable="true">推荐位名称</ th > < th data-field="scene" data-switchable="true">场景</ th > < th data-field="creater" data-switchable="true">创建者</ th > < th data-field="create_time" data-sortable="true" data-switchable="true">创建时间</ th > < th data-field="managers" data-switchable="true">授权账号</ th > </ tr > </ thead > </ table > </ div > |
场景二:混合开发或前后端未完全分离,前端人员不足或不成体系,按照bootstrapTable返回响应固定结构
{
rows:[],
total:100,
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | $( "#" + this .table).bootstrapTable({ url: '../data/bootstrap-table.json' , method: 'get' , //使用get方式请求服务器获取数据 queryParamsType : "" , dataField: "data" , queryParams:params=>{ this .param= this .getFormJson( this .formId) this .param[ "pageSize" ] = params.pageSize; this .param[ "pageNumber" ] = params.pageNumber this .param[ 'order' ] = params.order; this .param[ 'limit' ] = params.limit; return this .param ; }, onLoadSuccess: function (){ //加载成功时执行 }, onLoadError: function (){ //加载失败时执行 }, sidePagination : "server" , fixedColumns: true , fixedNumber: 0, height:getHeight() }); |
场景三:前后端完全分离状态,自定义响应结构体系,前端封装公共js库、ajax请求
function ajaxRequest(params){ //封装ajax 十里; $apis.users.getlist(function(re){ var message = rs.array; params.success({ //注意,必须返回参数 params total: rs.total, rows: res.list }); }) } $("#"+this.table).bootstrapTable({ ajax:ajaxRequest, onLoadSuccess: function(){ //加载成功时执行 }, onLoadError: function(){ //加载失败时执行 }, sidePagination : "server", fixedColumns: true, fixedNumber: 0, height:getHeight() });
简单事例、、虽说vue elementUI比这方便,但总有老系统还是使用旧的技术
标签:
bootstraptable
, bootstrap
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· 展开说说关于C#中ORM框架的用法!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?