fixed bug of Transfer when no slot
fixed bug of Transfer when no slot
This commit is contained in:
parent
7c2ed52c61
commit
84a8a413aa
3 changed files with 79 additions and 79 deletions
|
@ -11,7 +11,7 @@
|
|||
<Form-item prop="user">
|
||||
<Input v-model="formInline.user"></Input>
|
||||
</Form-item>
|
||||
<Form-item>
|
||||
<Form-item prop="targetKeys1">
|
||||
<Transfer
|
||||
:data="formInline.data1"
|
||||
:target-keys="formInline.targetKeys1"
|
||||
|
|
|
@ -1,77 +1,19 @@
|
|||
<!--<template>-->
|
||||
<!--<div>-->
|
||||
<!--<Transfer-->
|
||||
<!--:data="data1"-->
|
||||
<!--filterable-->
|
||||
<!--:target-keys="targetKeys1"-->
|
||||
<!--:render-format="render1"-->
|
||||
<!--@on-change="handleChange1"></Transfer>-->
|
||||
<!--</div>-->
|
||||
<!--</template>-->
|
||||
<!--<script>-->
|
||||
<!--export default {-->
|
||||
<!--data () {-->
|
||||
<!--return {-->
|
||||
<!--data1: this.getMockData(),-->
|
||||
<!--targetKeys1: this.getTargetKeys()-->
|
||||
<!--}-->
|
||||
<!--},-->
|
||||
<!--methods: {-->
|
||||
<!--getMockData () {-->
|
||||
<!--let mockData = [];-->
|
||||
<!--for (let i = 1; i <= 20; i++) {-->
|
||||
<!--mockData.push({-->
|
||||
<!--key: i.toString(),-->
|
||||
<!--label: '内容' + i,-->
|
||||
<!--description: '内容' + i + '的描述信息',-->
|
||||
<!--disabled: Math.random() * 3 < 1-->
|
||||
<!--});-->
|
||||
<!--}-->
|
||||
<!--return mockData;-->
|
||||
<!--},-->
|
||||
<!--getTargetKeys () {-->
|
||||
<!--return this.getMockData()-->
|
||||
<!--.filter(() => Math.random() * 2 > 1)-->
|
||||
<!--.map(item => item.key);-->
|
||||
<!--},-->
|
||||
<!--render1 (item) {-->
|
||||
<!--return item.label;-->
|
||||
<!--},-->
|
||||
<!--handleChange1 (newTargetKeys, direction, moveKeys) {-->
|
||||
<!--console.log(newTargetKeys);-->
|
||||
<!--console.log(direction);-->
|
||||
<!--console.log(moveKeys);-->
|
||||
<!--this.targetKeys1 = newTargetKeys;-->
|
||||
<!--}-->
|
||||
<!--}-->
|
||||
<!--}-->
|
||||
<!--</script>-->
|
||||
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<Transfer
|
||||
:data="data3"
|
||||
:target-keys="targetKeys3"
|
||||
:list-style="listStyle"
|
||||
:render-format="render3"
|
||||
:operations="['向左移动','向右移动']"
|
||||
:data="data1"
|
||||
filterable
|
||||
@on-change="handleChange3">
|
||||
<div :style="{float: 'right', margin: '5px'}">
|
||||
<Button type="ghost" size="small" @click.native="reloadMockData">刷新</Button>
|
||||
:target-keys="targetKeys1"
|
||||
:render-format="render1"
|
||||
@on-change="handleChange1"></Transfer>
|
||||
</div>
|
||||
</Transfer>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
data3: this.getMockData(),
|
||||
targetKeys3: this.getTargetKeys(),
|
||||
listStyle: {
|
||||
width: '250px',
|
||||
height: '300px'
|
||||
}
|
||||
data1: this.getMockData(),
|
||||
targetKeys1: this.getTargetKeys()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -92,20 +34,78 @@
|
|||
.filter(() => Math.random() * 2 > 1)
|
||||
.map(item => item.key);
|
||||
},
|
||||
handleChange3 (newTargetKeys) {
|
||||
this.targetKeys3 = newTargetKeys;
|
||||
render1 (item) {
|
||||
return item.label;
|
||||
},
|
||||
render3 (item) {
|
||||
return item.label + ' - ' + item.description;
|
||||
},
|
||||
reloadMockData () {
|
||||
this.data3 = this.getMockData();
|
||||
this.targetKeys3 = this.getTargetKeys();
|
||||
handleChange1 (newTargetKeys, direction, moveKeys) {
|
||||
console.log(newTargetKeys);
|
||||
console.log(direction);
|
||||
console.log(moveKeys);
|
||||
this.targetKeys1 = newTargetKeys;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<!--<template>-->
|
||||
<!--<Transfer-->
|
||||
<!--:data="data3"-->
|
||||
<!--:target-keys="targetKeys3"-->
|
||||
<!--:list-style="listStyle"-->
|
||||
<!--:render-format="render3"-->
|
||||
<!--:operations="['向左移动','向右移动']"-->
|
||||
<!--filterable-->
|
||||
<!--@on-change="handleChange3">-->
|
||||
<!--<div :style="{float: 'right', margin: '5px'}">-->
|
||||
<!--<Button type="ghost" size="small" @click.native="reloadMockData">刷新</Button>-->
|
||||
<!--</div>-->
|
||||
<!--</Transfer>-->
|
||||
<!--</template>-->
|
||||
<!--<script>-->
|
||||
<!--export default {-->
|
||||
<!--data () {-->
|
||||
<!--return {-->
|
||||
<!--data3: this.getMockData(),-->
|
||||
<!--targetKeys3: this.getTargetKeys(),-->
|
||||
<!--listStyle: {-->
|
||||
<!--width: '250px',-->
|
||||
<!--height: '300px'-->
|
||||
<!--}-->
|
||||
<!--}-->
|
||||
<!--},-->
|
||||
<!--methods: {-->
|
||||
<!--getMockData () {-->
|
||||
<!--let mockData = [];-->
|
||||
<!--for (let i = 1; i <= 20; i++) {-->
|
||||
<!--mockData.push({-->
|
||||
<!--key: i.toString(),-->
|
||||
<!--label: '内容' + i,-->
|
||||
<!--description: '内容' + i + '的描述信息',-->
|
||||
<!--disabled: Math.random() * 3 < 1-->
|
||||
<!--});-->
|
||||
<!--}-->
|
||||
<!--return mockData;-->
|
||||
<!--},-->
|
||||
<!--getTargetKeys () {-->
|
||||
<!--return this.getMockData()-->
|
||||
<!--.filter(() => Math.random() * 2 > 1)-->
|
||||
<!--.map(item => item.key);-->
|
||||
<!--},-->
|
||||
<!--handleChange3 (newTargetKeys) {-->
|
||||
<!--this.targetKeys3 = newTargetKeys;-->
|
||||
<!--},-->
|
||||
<!--render3 (item) {-->
|
||||
<!--return item.label + ' - ' + item.description;-->
|
||||
<!--},-->
|
||||
<!--reloadMockData () {-->
|
||||
<!--this.data3 = this.getMockData();-->
|
||||
<!--this.targetKeys3 = this.getTargetKeys();-->
|
||||
<!--}-->
|
||||
<!--}-->
|
||||
<!--}-->
|
||||
<!--</script>-->
|
||||
|
||||
<!--<template>-->
|
||||
<!--<Transfer-->
|
||||
<!--:data="data4"-->
|
||||
|
|
|
@ -67,8 +67,8 @@
|
|||
return cloned;
|
||||
}
|
||||
|
||||
const vNodes = this.$slots.default;
|
||||
const clonedVNodes = vNodes.map(vnode => cloneVNode(vnode));
|
||||
const vNodes = this.$slots.default === undefined ? [] : this.$slots.default;
|
||||
const clonedVNodes = this.$slots.default === undefined ? [] : vNodes.map(vnode => cloneVNode(vnode));
|
||||
|
||||
return createElement('div', {
|
||||
'class': this.classes
|
||||
|
|
Loading…
Add table
Reference in a new issue