我正在尝试用Vuetify实现vuedraggable
,但是由于某些原因,当卡片在一行时,拖放不起作用,但当它们在一列中时,拖放就起作用了。
看看这个有效的CodeSandbox。
在Parent.vue
文件中,如果删除包装<HelloWorld />
组件的<v-layout> </v-layout>
,卡片将进入一列,拖放操作将重新开始。
这是我的HelloWorld组件:
<template>
<v-flex xs4>
<v-card class="mx-4">
<v-img :src="src"></v-img>
<v-card-title primary-title>
<div>{{title}}</div>
</v-card-title>
</v-card>
</v-flex>
</template>
<script>
export default {
name: "HelloWorld",
props: {
title: String,
src: String,
id: Number
},
data() {
return {};
}
};
</script>
这是我的父组件:
<template>
<v-container>
<v-layout class="mt-5 align-center justify-center row fill-height">
<h2>Parent Component</h2>
</v-layout>
<draggable v-model="draggableCards">
<v-layout>
<template v-for="(tech,i) in getCardArray">
<HelloWorld :src="tech.src" :title="tech.title" :key="i"/>
</template>
</v-layout>
</draggable>
</v-container>
</template>
<script>
import { mapGetters, mapMutations } from "vuex";
import HelloWorld from "./HelloWorld";
import draggable from "vuedraggable";
export default {
components: {
draggable,
HelloWorld
},
computed: {
...mapGetters({
getCardArray: "getCardArray"
}),
draggableCards: {
get() {
return this.$store.state.cardArray;
},
set(val) {
this.$store.commit("setCardArray", val);
}
}
},
methods: {
...mapMutations({
setCardArray: "setCardArray"
})
}
};
</script>
如果有人能帮我解决这个问题,我一定会很感激的。谢谢。
发布于 2020-05-05 23:15:04
https://stackoverflow.com/questions/61616179
复制相似问题