vue+element-ui+ajax實現一個表格的執行個體,vueelement-ui

來源:互聯網
上載者:User

vue+element-ui+ajax實現一個表格的執行個體,vueelement-ui

執行個體如下:

<!DOCTYPE html><html><head><script src="js/jquery-3.2.1.js"></script><script src="vue.js"></script><!-- 引入樣式 --><link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css" 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實現一個表格的執行個體就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支援幫客之家。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.