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>
  • 相关阅读:
    《临江仙·滚滚长江东逝水》
    .net Core Newtonsoft.Json 解析巨坑之注释影响代码
    C# 后端post请求帮助类
    鼠标点击事件
    常用Windows 消息列表
    WinUser.h>>>OnMessage事件
    Jellyfin流媒体服务器搭建和一些小坑
    ios开发遇到的问题
    节省你的时间,用AHK实现随机打开文件
    一些简单的AHK脚本提升电脑使用体验
  • 原文地址:https://www.cnblogs.com/qdwz/p/11577955.html
Copyright © 2011-2022 走看看