• 测试后的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>
  • 相关阅读:
    占位
    阳光服务平台-敏捷开发
    两种方法实现带验证码的用户登录
    红警大战JAVA简单版
    JPanel与JFrame的区别
    java中import详解
    敏捷开发
    GitHub:本地项目上传与团队协作
    从结缘计算机到未来规划
    (三)微信小程序首页的分类功能和搜索功能的实现笔记
  • 原文地址:https://www.cnblogs.com/qdwz/p/11577955.html
Copyright © 2020-2023  润新知