vue+element-ui+ajax實現(xiàn)一個表格的實例
更新時間:2018年03月09日 10:32:24 作者:MrZero404
下面小編就為大家分享一篇vue+element-ui+ajax實現(xiàn)一個表格的實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
實例如下:
<!DOCTYPE html> <html> <head> <script src="js/jquery-3.2.1.js"></script> <script src="vue.js"></script> <!-- 引入樣式 --> <link rel="stylesheet" rel="external nofollow" > <!-- 引入組件庫 --> <script src="https://unpkg.com/element-ui/lib/index.js"></script> </head> <body> <div id="app"> <template> <el-table :data="tableData" style="width: 100%"> <el-table-column label="任務" width="180"> <template slot-scope="scope"> <el-popover trigger="hover" placement="top"> <p>姓名: {{ scope.row.name }}</p> <div slot="reference" class="name-wrapper"> <el-tag size="medium">{{ scope.row.name }}</el-tag> </div> </el-popover> </template> </el-table-column> <el-table-column label="歷時" width="180"> <template slot-scope="scope"> <i class="el-icon-time"></i> <span style="margin-left: 10px">{{ scope.row.take }}</span> </template> </el-table-column> <el-table-column label="開始時間" width="180"> <template slot-scope="scope"> <i class="el-icon-time"></i> <span style="margin-left: 10px">{{ scope.row.startTime }}</span> </template> </el-table-column> <el-table-column label="結束時間" width="180"> <template slot-scope="scope"> <i class="el-icon-time"></i> <span style="margin-left: 10px">{{ scope.row.finishTime }}</span> </template> </el-table-column> <el-table-column label="操作"> <template slot-scope="scope"> <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">編輯</el-button> <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">刪除</el-button> </template> </el-table-column> </el-table> </template> </div> <script type="text/javascript"> new Vue({ el:'#app', data:{ tableData: [], getUrl: 'http://localhost:8080/mytime/getTodayTomatos', }, created: function(){ this.getTableData() }, methods:{ getTableData:function(){ var self = this; $.ajax({ type : "post", dataType : "json", contentType : "application/json", url : "http://localhost:8080/mytime/getTodayTomatos", success : function(json) { self.tableData=json.fitomatos; }, error : function(json) { alert("加載失敗"); } }); }, handleEdit(index, row) { console.log(index, row.name); }, handleDelete(index, row) { console.log(index, row); } } }) </script> </body> </html>
效果圖:
以上這篇vue+element-ui+ajax實現(xiàn)一個表格的實例就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
您可能感興趣的文章:
- vue.js+Element實現(xiàn)表格里的增刪改查
- 詳解vue2.0的Element UI的表格table列時間戳格式化
- 利用vue + element實現(xiàn)表格分頁和前端搜索的方法
- Vue2.0+ElementUI實現(xiàn)表格翻頁的實例
- vue中element-ui表格縮略圖懸浮放大功能的實例代碼
- vue element-ui table表格滾動加載方法
- vue+element-ui實現(xiàn)表格編輯的三種實現(xiàn)方式
- VUE2.0+ElementUI2.0表格el-table循環(huán)動態(tài)列渲染的寫法詳解
- Vue+element-ui 實現(xiàn)表格的分頁功能示例
- Vue+Element實現(xiàn)表格編輯、刪除、以及新增行的最優(yōu)方法
相關文章
vue組件從開發(fā)到發(fā)布的實現(xiàn)步驟
這篇文章主要介紹了vue組件從開發(fā)到發(fā)布的實現(xiàn)步驟,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-11-11vue2利用Bus.js如何實現(xiàn)非父子組件通信詳解
這篇文章主要給大家介紹了關于vue2利用Bus.js如何實現(xiàn)非父子組件通信的相關資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧。2017-08-08使用vue實現(xiàn)滑動滾動條來加載數(shù)據(jù)
在vuejs中,我們經(jīng)常使用axios來請求數(shù)據(jù),但是有時候,我們請求的數(shù)據(jù)量很大,那么我們如何實現(xiàn)滑動滾動條來加載數(shù)據(jù)呢,接下來小編就給大家介紹一下在vuejs中如何實現(xiàn)滑動滾動條來動態(tài)加載數(shù)據(jù),需要的朋友可以參考下2023-10-10