vue+element-ui+ajax實(shí)現(xiàn)一個(gè)表格的實(shí)例
實(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)列渲染的寫法詳解
- Vue+element-ui 實(shí)現(xiàn)表格的分頁(yè)功能示例
- Vue+Element實(shí)現(xiàn)表格編輯、刪除、以及新增行的最優(yōu)方法
相關(guān)文章
vue element-ui表格自定義動(dòng)態(tài)列具體實(shí)現(xiàn)
這周工作中遇見(jiàn)了一個(gè)表格動(dòng)態(tài)列的需求,下面這篇文章主要給大家介紹了關(guān)于vue element-ui表格自定義動(dòng)態(tài)列具體實(shí)現(xiàn)的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2023-06-06
Vue實(shí)現(xiàn)導(dǎo)入Excel功能步驟詳解
這篇文章主要介紹了Vue實(shí)現(xiàn)導(dǎo)入Excel功能,本文分步驟給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-07-07
Vue3?Composition?API優(yōu)雅封裝第三方組件實(shí)例
這篇文章主要為大家介紹了Vue3?Composition?API優(yōu)雅封裝第三方組件實(shí)例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-07-07
VUE 配置vue-devtools調(diào)試工具及安裝方法
vue-devtools是一款基于chrome瀏覽器的插件,用于vue應(yīng)用的調(diào)試,這款vue調(diào)試神器可以極大地提高我們的調(diào)試效率。幫助我們快速的調(diào)試開(kāi)發(fā)vue應(yīng)用。這篇文章主要介紹了VUE 配置vue-devtools調(diào)試工具及安裝步驟 ,需要的朋友可以參考下2018-09-09
vue中的$emit 與$on父子組件與兄弟組件的之間通信方式
本文主要對(duì)vue 用$emit 與 $on 來(lái)進(jìn)行組件之間的數(shù)據(jù)傳輸。重點(diǎn)給大家介紹vue中的$emit 與$on父子組件與兄弟組件的之間通信方式,感興趣的朋友一起看看2018-05-05
Vue3使用v-html實(shí)現(xiàn)文本關(guān)鍵詞變色處理
遍歷文本內(nèi)容,找到關(guān)鍵詞,并使用某種方法更改其字體樣式,經(jīng)過(guò)搜尋資料決定采用v-html實(shí)現(xiàn),但是v-html本身并不安全,有安全性風(fēng)險(xiǎn)且影響性能,所以謹(jǐn)慎使用,本文給大家介紹了Vue3使用v-html實(shí)現(xiàn)文本關(guān)鍵詞變色處理,需要的朋友可以參考下2024-06-06
前端vue中el-table增加合計(jì)行及合并單元格代碼示例
在有些情況下我們會(huì)有合并表頭、合并列、合并尾部合計(jì)的需求,這篇文章主要給大家介紹了關(guān)于前端vue中el-table增加合計(jì)行及合并單元格的相關(guān)資料,需要的朋友可以參考下2023-09-09

