場景一:混合開發,适用jsp、php前端不足 純html結構
<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,
}
$("#"+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比這友善,但總有老系統還是使用舊的技術