vue+element-ui+ajax的一个表格实例

来源:互联网 发布:华中科技大学网络计算 编辑:程序博客网 时间:2024/05/29 15:47
<!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"><!-- 引入组件库 --><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>

效果图:



阅读全文
'); })();
0 0
原创粉丝点击
热门IT博客
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 领克的质量可靠吗 吉利汽车领克01 领克商城 领克03旅行版 领了克03 领克03phev 领克02价格报价及图片 领了克01怎么样 领克01售价 领克3图片 领克07 领克跑车 领克贷款方案 领克3怎么样 2019款领克 领克吧 领克001 领克02是什么牌子的车 领克汽车02 领克02上市时间及价格 领克02参数 领克01质量怎么样 领克03试驾 领克02内饰 领克02吧 领克5 03领克 领克中型suv 汽车领克02 领克汽车怎么样 领克和逍客哪个好 领克的价格 领克02油耗 领克02优惠 领克o1 领克o2 领克03报价及图片 领克01价格多少 领克02价位 新款领克 领克新款