vue transfer 使用

vue  transfer 使用

 

 

直接上代码:

<template>
    <div>
        <div class="transfer-selection">
            <a-popover>
                <template slot="content">
                    左边为数据源,右侧为要提交的数据
                </template>
                <span  style="color:yellowgreen" ></span>温馨提示 </span><a-icon type="question-circle" />
            </a-popover>
        </div>
        <div >
            <a-transfer
            :data-source="mockData"
            show-search
            :list-style="{
              width: '45%',
              height: '600px',
            }"
          
            :target-keys="targetKeys"
            :render="item => `${item.title}-${item.description}`"
            @change="handleChange"
          >
      
            <span slot="notFoundContent">
              没数据
            </span>
          </a-transfer>
        </div>
    </div>

  </template>
  <script>
  export default {
    data() {
      return {
        mockData: [],
        targetKeys: [],
      };
    },
    mounted() {
      this.getMock();
    },
    methods: {
        getMock() {
        const targetKeys = [];
        const mockData =[{'key':1,'title':"xxxx1",description:"desc1"},{'key':2,'title':"xxxx2",description:"desc1"}];
        this.mockData = mockData;
        this.targetKeys = targetKeys;
    },

      handleChange(targetKeys, direction, moveKeys) {
        console.log(targetKeys, direction, moveKeys);
        this.targetKeys = targetKeys;
        for (let item of moveKeys){
            if (targetKeys.indexOf(item) == -1)
            targetKeys.push(moveKeys)
        }
        
      },
    },
  };
  </script>



<style lang="less">

.transfer-selection{

    margin-bottom:30px ;
}
</style>

  

 

上一篇:fastapi六:fastapi接口常用配置参数


下一篇:Github搜索技巧