欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue實(shí)現(xiàn)動(dòng)態(tài)表格提交參數(shù)動(dòng)態(tài)生成控件的操作

 更新時(shí)間:2020年11月09日 15:36:58   作者:被迫前端的后端  
這篇文章主要介紹了vue實(shí)現(xiàn)動(dòng)態(tài)表格提交參數(shù)動(dòng)態(tài)生成控件的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧

上面要求做一個(gè)根據(jù)后臺(tái)數(shù)據(jù)動(dòng)態(tài)生成控件,然后讓用戶輸入提交查詢信息,然后動(dòng)態(tài)生成表格在顯示出來(lái)。動(dòng)態(tài)控件代碼如下

<el-form
    :model="formData"
    style="padding: 0 5px;">
    <div v-if="tableshow">
    <div v-for="(item,i) in control" :key="i" style="padding-left:10px; float:left" >
     <el-form-item
     v-if="item.type=='input'"
     :key="item.name"
     :prop="item.name"
     label-width="100px">
     <label slot="label">{{ item.cnname }}:</label>
     <el-input v-model="item.value" size="mini" style="width: 100px; padding-right: 5px;"/>
     </el-form-item>
     <el-form-item
     v-if="item.type=='time'"
     :key="item.name"
     :prop="item.name"
     label-width="100px">
     <label slot="label">{{ item.cnname }}:</label>
     <el-date-picker
      v-model="item.value"
      value-format="yyyy-MM-dd HH:mm:ss"
      type="date"
      placeholder="選擇日期"/>
     </el-form-item>
    </div>
    <div style="padding-left:10px; float:left">
     <el-form-item prop="name" style="width: 20px; margin-bottom: 0px;">
     <el-button class="filter-item" type="primary" icon="el-icon-search" size="mini" @click="cmdsearch">
      {{ $t('table.search') }}
     </el-button>
     </el-form-item>
    </div>
    </div>
   </el-form>

data格式如下

 control: [{
  name: 'input1',
  cnname: '輸入框1',
  type: 'input',
  value: '這里'
  }, {
  name: 'time1',
  cnname: '時(shí)間范圍',
  type: 'time',
  value: null
  }]

還要監(jiān)聽(tīng)所有控件變化

 computed: {
 // 監(jiān)聽(tīng)所有控件變化
 formData: function() {
  var formData = {}
  this.control.forEach((item) => {
  formData[item.name] = item.value
  })
  return formData
 }
 }

動(dòng)態(tài)表格如下

<el-table
    v-if="tableshow"
    id="exportTab"
    ref="multipleTable"
    :data="tables"
    border="true"
    tooltip-effect="dark"
    style="width: 100%;"
    @selection-change="selectArInfo">
    <el-table-column fixed="left" label="序號(hào)" width="62px" type="index"/>
    <template v-for="(col) in tableData">
    <el-table-column
     :show-overflow-tooltip="true"
     :formatter="fmtLength"
     :prop="col.dataItem"
     :label="col.dataName"
     :key="col.dataItem"
     resizable="true"
     width="120px"/>
    </template>
   </el-table>

需要兩個(gè)數(shù)組,一個(gè)保存表格列名,一個(gè)保存表格數(shù)據(jù)

 tables: [], 
  tableData: [dataItem: xxx,
   dataName: xxx], //保存表格列名

補(bǔ)充知識(shí):vue table表格的使用(動(dòng)態(tài)數(shù)據(jù)展示)

第一種方式

 <el-table :data="tableDataalllist" border style="width: 100%" @sort-change="totalusercount">
  <el-table-column :label="head" :prop="head" v-for="(head, index) in header" :key="head" :sortable="定義自定義排序項(xiàng)">
  <template slot-scope="scope">
  {{tableDataalllist[scope.$index][index]}} // 當(dāng)前行數(shù)據(jù) 接收兩個(gè)參數(shù)scope.$index; scope.row
  <template>
  <el-table-column>
 <el-table>
<script>
 export default{
  data(){
   return{
   // 數(shù)據(jù)結(jié)構(gòu)
    tableDataalllist:[{
     1,'張三','23'
    },{
     2,'李四','15'
    },{
     3,'王五','18'
    }],
    header:['id','name','age']
   } 
  },
  methods:{
  // 接受一個(gè)obj參數(shù)
   totalusercount(obj){
    console.log(obj.prop) // 排序規(guī)則
    console.log(obj.order) // 排序方式
   }
  }
 }
</script>
id name age
1 張三 23
2 李四 15
3 王五 18

第二種方式(動(dòng)態(tài)進(jìn)行列的添加)

<el-table :data="gameareatable" v-loading="cardBuyConsumeDataLoading" v-if="gameareatable.length> 0">
 <el-table-column align="center" v-for="(item,index) in activePlayerDataPropLabelArray" :prop="item.prop" :label="item.label"
  :key="item.prop">
  <template slot-scope="scope">
  {{scope.row[item.prop]?scope.row[item.prop]:'暫無(wú)數(shù)據(jù)'}}
  </template>
 </el-table-column>
 </el-table>

export default {
 data(){
  return{
  // 數(shù)據(jù)結(jié)構(gòu) activePlayerDataPropLabelArray為label標(biāo)簽顯示label表示當(dāng)前列th的顯示的值,prop表示當(dāng)前'日期'列下顯示date數(shù)據(jù),'斗地主'列下顯示prop為12的數(shù)據(jù),'麻將'列下顯示prop為15的數(shù)據(jù),
   activePlayerDataPropLabelArray:[{
    label:'日期',
    prop:'date'
   },{
    label:"斗地主",
    prop:"12"
   },{
    label:'麻將',
    prop:'15'
   }],
   gameareatable:[{
    date:"2018-09-10",
    12:'老k',
    15:'一萬(wàn)'
   },{
    date:"2018-08-01",
    12:'炸彈',
    15:'一條' 
   },{
    date:"2018-08-02",
    12:'對(duì)子',
    15:'五筒' 
   }]
  }
 }
}
日期 斗地主 麻將
2018-09-10 老k 一萬(wàn)
2018-08-01 炸彈 一條
2018-08-02 對(duì)子 一萬(wàn)

以上這篇vue實(shí)現(xiàn)動(dòng)態(tài)表格提交參數(shù)動(dòng)態(tài)生成控件的操作就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Vue實(shí)現(xiàn)Tab選項(xiàng)卡切換

    Vue實(shí)現(xiàn)Tab選項(xiàng)卡切換

    這篇文章主要為大家詳細(xì)介紹了Vue實(shí)現(xiàn)Tab選項(xiàng)卡切換,點(diǎn)擊不同標(biāo)題顯示對(duì)應(yīng)圖片,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-09-09
  • Vue實(shí)現(xiàn)導(dǎo)出word文檔的示例詳解

    Vue實(shí)現(xiàn)導(dǎo)出word文檔的示例詳解

    這篇文章主要為大家詳細(xì)介紹了Vue如何使用第三方庫(kù)file-saver和html-docx-js實(shí)現(xiàn)導(dǎo)出word文檔的效果,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2024-02-02
  • vue新建環(huán)境變量以及網(wǎng)絡(luò)請(qǐng)求工具axios的二次封裝詳解

    vue新建環(huán)境變量以及網(wǎng)絡(luò)請(qǐng)求工具axios的二次封裝詳解

    這篇文章主要為大家介紹了vue新建環(huán)境變量以及網(wǎng)絡(luò)請(qǐng)求工具axios的二次封裝詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-06-06
  • 詳解vue-router 命名路由和命名視圖

    詳解vue-router 命名路由和命名視圖

    這篇文章主要介紹了詳解vue-router 命名路由和命名視圖,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-06-06
  • 如何利用vue3實(shí)現(xiàn)一個(gè)俄羅斯方塊

    如何利用vue3實(shí)現(xiàn)一個(gè)俄羅斯方塊

    俄羅斯方塊這個(gè)游戲相信大家都玩過(guò),下面這篇文章主要給大家介紹了關(guān)于如何利用vue3實(shí)現(xiàn)一個(gè)俄羅斯方塊的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2022-01-01
  • Vue子父組件之間傳值的三種方法示例

    Vue子父組件之間傳值的三種方法示例

    Vue的組件化給前端開(kāi)發(fā)帶來(lái)極大的便利,下面這篇文章主要給大家介紹了關(guān)于Vue子父組件之間傳值的三種方法,文中通過(guò)代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2024-02-02
  • 關(guān)于vue父組件調(diào)用子組件的方法

    關(guān)于vue父組件調(diào)用子組件的方法

    本文主要介紹了vue父組件調(diào)用子組件的方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2022-04-04
  • iview-table組件嵌套input?select數(shù)據(jù)無(wú)法雙向綁定解決

    iview-table組件嵌套input?select數(shù)據(jù)無(wú)法雙向綁定解決

    這篇文章主要為大家介紹了iview-table組件嵌套input?select數(shù)據(jù)無(wú)法雙向綁定解決示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-09-09
  • Vue實(shí)現(xiàn)調(diào)用PC端攝像頭實(shí)時(shí)拍照

    Vue實(shí)現(xiàn)調(diào)用PC端攝像頭實(shí)時(shí)拍照

    這篇文章主要為大家詳細(xì)介紹了Vue實(shí)現(xiàn)調(diào)用PC端攝像頭實(shí)時(shí)拍照,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-09-09
  • vue3實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn)的示例代碼

    vue3實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn)的示例代碼

    這篇文章給大家介紹了vue3如何實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn),文中通過(guò)代碼示例給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作有一定的幫助,需要的朋友可以參考下
    2024-02-02

最新評(píng)論