vue+element-ui+ajax實(shí)現(xiàn)一個(gè)表格的實(shí)例
更新時(shí)間:2018年03月09日 10:32:24 作者:MrZero404
下面小編就為大家分享一篇vue+element-ui+ajax實(shí)現(xiàn)一個(gè)表格的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
實(shí)例如下:
<!DOCTYPE html>
<html>
<head>
<script src="js/jquery-3.2.1.js"></script>
<script src="vue.js"></script>
<!-- 引入樣式 -->
<link rel="stylesheet" rel="external nofollow" >
<!-- 引入組件庫(kù) -->
<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="任務(wù)" 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="歷時(shí)" 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="開(kāi)始時(shí)間" 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="結(jié)束時(shí)間" 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實(shí)現(xiàn)一個(gè)表格的實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
您可能感興趣的文章:
- vue.js+Element實(shí)現(xiàn)表格里的增刪改查
- 詳解vue2.0的Element UI的表格table列時(shí)間戳格式化
- 利用vue + element實(shí)現(xiàn)表格分頁(yè)和前端搜索的方法
- Vue2.0+ElementUI實(shí)現(xiàn)表格翻頁(yè)的實(shí)例
- vue中element-ui表格縮略圖懸浮放大功能的實(shí)例代碼
- vue element-ui table表格滾動(dòng)加載方法
- vue+element-ui實(shí)現(xiàn)表格編輯的三種實(shí)現(xiàn)方式
- VUE2.0+ElementUI2.0表格el-table循環(huán)動(dòng)態(tài)列渲染的寫(xiě)法詳解
- Vue+element-ui 實(shí)現(xiàn)表格的分頁(yè)功能示例
- Vue+Element實(shí)現(xiàn)表格編輯、刪除、以及新增行的最優(yōu)方法
相關(guān)文章
vue組件從開(kāi)發(fā)到發(fā)布的實(shí)現(xiàn)步驟
這篇文章主要介紹了vue組件從開(kāi)發(fā)到發(fā)布的實(shí)現(xiàn)步驟,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-11-11
vue2.x中keep-alive源碼解析(實(shí)例代碼)
Keep-Alive模式避免頻繁創(chuàng)建、銷毀鏈接,允許多個(gè)請(qǐng)求和響應(yīng)使用同一個(gè)HTTP鏈接,這篇文章主要介紹了vue2.x中keep-alive源碼解析,需要的朋友可以參考下2023-02-02
vue2利用Bus.js如何實(shí)現(xiàn)非父子組件通信詳解
這篇文章主要給大家介紹了關(guān)于vue2利用Bus.js如何實(shí)現(xiàn)非父子組件通信的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。2017-08-08
使用vue實(shí)現(xiàn)滑動(dòng)滾動(dòng)條來(lái)加載數(shù)據(jù)
在vuejs中,我們經(jīng)常使用axios來(lái)請(qǐng)求數(shù)據(jù),但是有時(shí)候,我們請(qǐng)求的數(shù)據(jù)量很大,那么我們?nèi)绾螌?shí)現(xiàn)滑動(dòng)滾動(dòng)條來(lái)加載數(shù)據(jù)呢,接下來(lái)小編就給大家介紹一下在vuejs中如何實(shí)現(xiàn)滑動(dòng)滾動(dòng)條來(lái)動(dòng)態(tài)加載數(shù)據(jù),需要的朋友可以參考下2023-10-10
解決vue頁(yè)面刷新或者后退參數(shù)丟失的問(wèn)題
下面小編就為大家分享一篇解決vue頁(yè)面刷新或者后退參數(shù)丟失的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-03-03
Vue使用lodop實(shí)現(xiàn)打印小結(jié)
這篇文章主要介紹了Vue使用lodop打印小結(jié),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-07-07

