vue+element-ui+ajax を使用してテーブルの例を実装する

亚连
リリース: 2018-05-31 15:41:00
オリジナル
3012 人が閲覧しました

ここで、vue+element-ui+ajax を使用してフォームを実装する例を紹介します。これは非常に参考になるので、皆さんのお役に立てれば幸いです。

例は次のとおりです:

<!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>
 
<p 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>
   <p slot="reference" class="name-wrapper">
   <el-tag size="medium">{{ scope.row.name }}</el-tag>
   </p>
  </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>
</p> 
 <script type="text/javascript">
 new Vue({
 el:&#39;#app&#39;,
 data:{
  tableData: [],
  getUrl: &#39;http://localhost:8080/mytime/getTodayTomatos&#39;,
 },
 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>
ログイン後にコピー

レンダリング:

上記は、将来皆さんに役立つことを願っています。

関連記事:

JavaScriptは、フェードインおよびフェードアウト効果の関数テストサンプルコードをネイティブにカプセル化します

react-native-videoメソッドで全画面ビデオ再生を実装します

vueでツリーを実装しますメニュー効果

以上がvue+element-ui+ajax を使用してテーブルの例を実装するの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

関連ラベル:
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!