zoukankan      html  css  js  c++  java
  • 测试后的iview的表格

    <template>
      <GPage bg>
        <div>
          <div class="table">
            <Button class="button"
                    @click="add">Add</Button>
            <Table :columns="columns"
                   :data="data"
                   class="table-fixbug"></Table>
          </div>
        </div>
      </GPage>
    </template>
    <script>
    export default {
      name: 'HelloWorld',
      data () {
        return {
          columns: [
            {
              type: 'selection',
               60,
              align: 'center'
            },
            {
              title: '姓名',
              key: 'name',
              render: (h, { row, index }) => {
                return h('Input', {
                  props: {
                    value: row.name
                  },
                  on: {
                    input: val => {
                      this.data[index].name = val
                    }
                  }
                })
              }
            },
            {
              title: '爱好',
              key: 'hobby',
              render: (h, { row, index }) => {
                return h('Select', {
                  props: {
                    value: row.hobby
                  },
                  on: {
                    'on-select': val => {
                      this.data[index].hobby = val
                    }
                  }
                },
                this.options.map(item => {
                  return h('Option', {
                    props: {
                      value: item,
                      label: item
                    }
                  })
                })
                )
              }
            },
            {
              title: '职业',
              key: 'job',
              render: (h, { row, index }) => {
                return h('Input', {
                  props: {
                    value: row.job
                  },
                  on: {
                    input: val => {
                      this.data[index].job = val
                    }
                  }
                })
              }
            },
            {
              title: 'operation',
              key: 'operation',
              render: (h, { row, index }) => {
                return h(
                  'a',
                  {
                    on: {
                      click: () => {
                        this.data.splice(index, 1)
                      }
                    }
                  },
                  'Delete'
                )
              }
            }
          ],
          data: [
            {
              name: '',
              hobby: '',
              job: ''
            }
          ],
          options: ['电影', '游戏', '看书']
        }
      },
      methods: {
        add () {
          const addData = {
            name: '',
            hobby: '',
            job: ''
          }
          this.data.push(addData)
        }
      }
    }
    </script>
    <style lang="less" scoped>
    .table {
      text-align: left;
    }
    .button {
      margin-bottom: 20px;
    }
    .table-fixbug {
      overflow: visible;
    }
    </style>
  • 相关阅读:
    MVC5+EF6简单实例以原有SQLServer数据库两表联合查询为例
    ArcGIS生成根据点图层生成等值面并减小栅格锯齿的操作步骤
    EF6+MVC5之Oracleo数据库的Code First方式实现
    jquery写的tab切换效果 非常简单
    APP消息推送是否进入消息中心和click、receive事件分析
    Android APP切换到后台接收不到推送消息
    js写的简单轮播图
    凉凉的笔记 two day
    凉凉的笔记 one.day
    在SQL Server数据库中批量导入数据的四种方法
  • 原文地址:https://www.cnblogs.com/qdwz/p/11577955.html
Copyright © 2011-2022 走看看