vue封裝自定義組件之tabal列表編輯單元格組件實例代碼

vue 封裝自定義組件

創(chuàng)新互聯(lián)是一家集網(wǎng)站建設,曾都企業(yè)網(wǎng)站建設,曾都品牌網(wǎng)站建設,網(wǎng)站定制,曾都網(wǎng)站建設報價,網(wǎng)絡營銷,網(wǎng)絡優(yōu)化,曾都網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強企業(yè)競爭力。可充分滿足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時我們時刻保持專業(yè)、時尚、前沿,時刻以成就客戶成長自我,堅持不斷學習、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實用型網(wǎng)站。

tabal列表編輯單元格組件

<template>
 <div class="editable-cell">
  <div class="editable-cell-input-wrapper" v-if='editable'>
   <el-input class="editInput" v-model="cellValue" placeholder="請輸入內容" v-loading="editLoading" size="small"></el-input>
   <el-button type="text"><i class="el-icon-check" @click='check'></i></el-button>
  </div>
  <div class="editable-cell-text-wrapper" v-else>
   {{cellValue || ' '}}
   <el-button type="text"><i class="el-icon-edit" @click='edit'></i></el-button>
  </div>
 </div>
</template>
<script>
import util from '../../common/js/util';
import $ from 'jquery';
import axios from './../../common/ajax/axios.js';
export default { 
 data() {
  return { 
   cellValue:this.value,
   editable:false,
   editLoading:false,
  };
 },
 props : [
  'value'
 ],
 methods: {
  check(){
   const self = this;
   function callback(){
    self.editLoading = false;
    self.editable=false;
   }
   this.editLoading = true;
   self.$emit('cellChange',self.cellValue,callback)
  },
  edit(){
   this.editable = true;
  }
 }
};
</script>
<style lang="less" scoped>
.taskDetail{
 margin-left: 10px;
 margin-top:10px;
}
.editInput{
 width: 200px;
 height: 30px;
}
.el-icon-edit{
 margin-left: 20px;
}
.el-icon-check{
 margin-left: 20px;
}
</style>
<style>
.editInput .el-loading-spinner .circular{
 width:20px;
}
</style>

vue 封裝自定義組件之tabal列表編輯單元格組件實例代碼

解釋一下:

props:父組件傳遞給子組件的值;

$emit(‘方法名',數(shù)據(jù)) 返回父級數(shù)據(jù),會觸發(fā)父組件中調用子組件的方法;

父組件中的使用方法:

vue 封裝自定義組件之tabal列表編輯單元格組件實例代碼

1.先將組件import 進來;

2.然后將組件暴露出去,這樣父組件就可以用了;

vue 封裝自定義組件之tabal列表編輯單元格組件實例代碼

總結

以上所述是小編給大家介紹的vue 封裝自定義組件tabal列表編輯單元格組件,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對創(chuàng)新互聯(lián)網(wǎng)站的支持!

本文名稱:vue封裝自定義組件之tabal列表編輯單元格組件實例代碼
網(wǎng)頁鏈接:http://muchs.cn/article28/joppcp.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站建設、建站公司、移動網(wǎng)站建設做網(wǎng)站、網(wǎng)站策劃、搜索引擎優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

外貿網(wǎng)站制作