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

Vue實(shí)現(xiàn)用戶自定義字段顯示數(shù)據(jù)的方法

 更新時(shí)間:2018年08月28日 10:48:14   作者:codingNoob  
今天小編就為大家分享一篇Vue實(shí)現(xiàn)用戶自定義字段顯示數(shù)據(jù)的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來(lái)看看吧

如下:

代碼:

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <script src="../lib/vue.min.js"></script>
  <style>
    .middle::-webkit-scrollbar {height:8px;}
    /* 滾動(dòng)槽 */
    .middle::-webkit-scrollbar-track {border-radius: 10px;}
    /* 滾動(dòng)條滑塊 */
    .middle::-webkit-scrollbar-thumb {background: #ccc;}
    * {margin: 0;padding: 0;box-sizing:border-box;font-family: "微軟雅黑";}
    #tabPanel{width:1100px;height:300px;margin:100px auto;}
    .left{float:left;height:300px;width:300px;font-size:0;}
    .left .item,.right .item,.middle .item{display:inline-block;width:100px;}
    .left .item span,.middle .item span,.left .item span{display:block;height:50px;text-align:center;line-height:50px;font-size:14px;border:1px solid #eee;}
    .right .item{width:200px;height:50px;line-height:50px;text-align:center;border:1px solid #eee;}
    .right .item span{display:inline-block;border:none;color:blue;text-decoration: underline;cursor:pointer;}
    .middle{float:left;height:300px;width:300px;font-size:0;overflow-x:scroll;overflow-y:hidden;}
    .right{float:left;height:300px;width:200px;}
    #tabPanel .chooseItem {padding:10px 0;}
    #tabPanel .chooseItem label{padding:0 10px;}
  </style>
  <title>Vue實(shí)現(xiàn)自定義字段數(shù)據(jù)</title>
</head>

<body>

  <div id="tabPanel">
    <div class="chooseItem">
      <label @click="chooseFile()"><input type="checkbox" @click.stop="" v-model="field.weight">體重</label>
      <label @click="chooseFile()"><input type="checkbox" @click.stop="" v-model="field.inter">興趣</label>
      <label @click="chooseFile()"><input type="checkbox" @click.stop="" v-model="field.schoold">學(xué)校</label>
      <label @click="chooseFile()"><input type="checkbox" @click.stop="" v-model="field.district">所屬地區(qū)</label>
      <label @click="chooseFile()"><input type="checkbox" @click.stop="" v-model="field.class">所屬年級(jí)</label>
      <label @click="chooseFile()"><input type="checkbox" @click.stop="" v-model="field.math">數(shù)學(xué)</label>
      <label @click="chooseFile()"><input type="checkbox" @click.stop="" v-model="field.chinese">語(yǔ)文</label>
      <label @click="chooseFile()"><input type="checkbox" @click.stop="" v-model="field.english">英語(yǔ)</label>
    </div>
    <div class="left">
      <div class="item">
        <span>編號(hào)</span>
        <span v-for="(item, index) in students">{{item.id}}</span>
      </div>
      <div class="item">
        <span>姓別</span>
        <span v-for="(item, index) in students">{{item.sex}}</span>
      </div>
      <div class="item">
        <span>身高</span>
        <span v-for="(item, index) in students">{{item.hight}}</span>
      </div>
    </div>
    <div class="middle">
      <div :style="{width: (length*100) + 'px'}">
        <div class="item" v-show="field.weight">
          <span>體重</span>
          <span v-for="(item, index) in students">{{item.weight}}</span>
        </div>
        <div class="item" v-show="field.inter">
          <span>興趣</span>
          <span v-for="(item, index) in students">{{item.inter}}</span>
        </div>
        <div class="item" v-show="field.schoold">
          <span>學(xué)校</span>
          <span v-for="(item, index) in students">{{item.schoold}}</span>
        </div>
        <div class="item" v-show="field.district">
          <span>所屬地區(qū)</span>
          <span v-for="(item, index) in students">{{item.district}}</span>
        </div>
        <div class="item" v-show="field.class">
          <span>所屬年級(jí)</span>
          <span v-for="(item, index) in students">{{item.class}}</span>
        </div>
        <div class="item" v-show="field.math">
          <span>數(shù)學(xué)</span>
          <span v-for="(item, index) in students">{{item.math}}</span>
        </div>
        <div class="item" v-show="field.chinese">
          <span>語(yǔ)文</span>
          <span v-for="(item, index) in students">{{item.chinese}}</span>
        </div>
        <div class="item" v-show="field.english">
          <span>英語(yǔ)</span>
          <span v-for="(item, index) in students">{{item.english}}</span>
        </div>
      </div>
    </div>
    <div class="right">
      <div class="item">
        <span>操作</span>
      </div>
      <div class="item" v-for="(item, index) in students">
        <span @click="detail(item.id ,index)" :title="item.id">查看</span>
        <span @click="detail(item.id ,index)" :title="item.id">刪除</span>
        <span @click="detail(item.id ,index)" :title="item.id">修改</span>
        <span @click="detail(item.id ,index)" :title="item.id">凍結(jié)</span>
      </div>
    </div>
  </div>
</body>
<script>
  var v = new Vue({
    el: "#tabPanel",
    data: {
      length: 3,
      field:{
        weight: true,
        inter: true,
        schoold: true,
        district: false,
        class: false,
        math: false,
        chinese: false,
        english: false
      },
      students:[{
        id: 1,
        name: 'zhangsan01',
        sex: '男',
        hight: '168cm',
        weight: '56kg',
        inter: '籃球1',
        schoold: '清華大學(xué)1',
        district: '湖南省1',
        class: '大學(xué)三年級(jí)1',
        math: '97',
        chinese: '98',
        english: '120'
      },{
        id: 2,
        name: 'zhangsan02',
        sex: '男',
        hight: '168cm',
        weight: '56kg',
        inter: '籃球2',
        schoold: '清華大學(xué)2',
        district: '湖南省2',
        class: '大學(xué)三年級(jí)2',
        math: '97',
        chinese: '98',
        english: '120'
      },{
        id: 3,
        name: 'zhangsan03',
        sex: '男',
        hight: '168cm',
        weight: '56kg',
        inter: '籃球3',
        schoold: '清華大學(xué)3',
        district: '湖南省3',
        class: '大學(xué)三年級(jí)3',
        math: '97',
        chinese: '98',
        english: '120'
      },{
        id: 4,
        name: 'zhangsan04',
        sex: '男',
        hight: '168cm',
        weight: '56kg',
        inter: '籃球4',
        schoold: '清華大學(xué)4',
        district: '湖南省4',
        class: '大學(xué)三年級(jí)4',
        math: '97',
        chinese: '98',
        english: '120'
      },{
        id: 5,
        name: 'zhangsan05',
        sex: '男',
        hight: '168cm',
        weight: '56kg',
        inter: '籃球5',
        schoold: '清華大學(xué)5',
        district: '湖南省5',
        class: '大學(xué)三年級(jí)5',
        math: '97',
        chinese: '98',
        english: '120'
      }]
    },
    methods: {
      //雙擊刪除滑塊
      del: function(index) {
        this.tabs.splice(index, 1);
        this.tabContents.splice(index, 1)
      },
      //編輯選項(xiàng)內(nèi)容
      editContent: function(index, value) {
        this.tabContents[index] = value;
        console.log(this.tabContents);
      },
      chooseFile: function(){
        var val = this.field;
        //this.length = 0;
        for (i in val){
          if(val[i]){
            this.length = this.length + 1;
          }
          //console.log(val.lenght)
        }
        if(this.length > 8){
          this.length = 8;
        }
        console.log(this.length);
      }
    },
    computed: {
      lengthb: function(){
        if(length > 6){
          lengthb = 6
        }
      }
    },
    watch: {
      field: function(val){

        //console.log(this.field.lenght);
      }
    }
  });
</script>

</html>

以上這篇Vue實(shí)現(xiàn)用戶自定義字段顯示數(shù)據(jù)的方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • 在Vue.js應(yīng)用中實(shí)現(xiàn)分布式搜索和全文搜索

    在Vue.js應(yīng)用中實(shí)現(xiàn)分布式搜索和全文搜索

    分布式搜索和全文搜索在現(xiàn)代應(yīng)用程序中變得越來(lái)越重要,因?yàn)樗鼈兛梢詭椭脩艨焖俨檎液蜋z索大量數(shù)據(jù),Elasticsearch是一種強(qiáng)大的分布式搜索引擎,本文將介紹如何在Vue.js應(yīng)用程序中實(shí)現(xiàn)分布式搜索和全文搜索,以及如何與Elasticsearch集成,需要的朋友可以參考下
    2023-11-11
  • Vue-drag-resize 拖拽縮放插件的使用(簡(jiǎn)單示例)

    Vue-drag-resize 拖拽縮放插件的使用(簡(jiǎn)單示例)

    本文通過代碼給大家介紹了Vue-drag-resize 拖拽縮放插件使用簡(jiǎn)單示例,代碼簡(jiǎn)單易懂,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-12-12
  • 淺析vue-router中params和query的區(qū)別

    淺析vue-router中params和query的區(qū)別

    這篇文章主要介紹了vue-router中params和query的區(qū)別,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-12-12
  • vue實(shí)現(xiàn)簡(jiǎn)單表格組件實(shí)例詳解

    vue實(shí)現(xiàn)簡(jiǎn)單表格組件實(shí)例詳解

    vue的核心思想就是組件,什么是組件呢?按照我的理解組件就是裝配頁(yè)面的零件,vue三大核心組件 路由 狀態(tài)管理,路由控制頁(yè)面的渲染,頁(yè)面由組件組成,數(shù)據(jù)有vuex進(jìn)行管理和改變。下面我會(huì)以一個(gè)簡(jiǎn)單的案例來(lái)說(shuō)
    2017-04-04
  • Vue中全局限制輸入特殊字符方式

    Vue中全局限制輸入特殊字符方式

    這篇文章主要介紹了Vue中全局限制輸入特殊字符方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-03-03
  • 關(guān)于nuxt?store中保存localstorage的問題

    關(guān)于nuxt?store中保存localstorage的問題

    這篇文章主要介紹了關(guān)于nuxt?store中保存localstorage的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-10-10
  • vue2滾動(dòng)條加載更多數(shù)據(jù)實(shí)現(xiàn)代碼

    vue2滾動(dòng)條加載更多數(shù)據(jù)實(shí)現(xiàn)代碼

    本篇文章主要介紹了vue2滾動(dòng)條加載更多數(shù)據(jù)實(shí)現(xiàn)代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧
    2017-01-01
  • Vue使用electron生成桌面應(yīng)用過程詳解

    Vue使用electron生成桌面應(yīng)用過程詳解

    這篇文章主要介紹了Vue使用electron生成桌面應(yīng)用過程,很想使用 electron 制作一個(gè)桌面應(yīng)用,但是真的上手使用的時(shí)候才發(fā)現(xiàn) electron 的坑實(shí)在是太多了,先將遇到的坑記錄在這里,遇到一個(gè)記錄一個(gè)
    2023-04-04
  • vue如何解決代碼需要在dom渲染之后執(zhí)行問題

    vue如何解決代碼需要在dom渲染之后執(zhí)行問題

    這篇文章主要介紹了vue如何解決代碼需要在dom渲染之后執(zhí)行問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-03-03
  • TypeScript基本類型 typeof 和keyof案例詳解

    TypeScript基本類型 typeof 和keyof案例詳解

    這篇文章主要介紹了TypeScript基本類型 typeof 和keyof案例詳解,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-10-10

最新評(píng)論