我编写了一个在整个应用程序中共享的组件,在某些地方我需要拖动/排序,而有些地方不希望它在那里。我通过了 prop
到我名为 disableDraggable
的组件并基于它应该禁用,不幸的是它没有做任何事情,我如何禁用可拖动?
我应该注意到我尝试了选项对象语法和一个简单的 :disable
,这里是相关的代码:
<draggable v-model="copyOfQuestions" @end="$emit('updateQuestionsOrder', copyOfQuestions)" :options="{disable : disableDraggable}">
// or :disable="disableDraggable"
<v-card flat class="list_outer_block" v-for="q in questions" :key="q.question_id">
<v-card-text class="pa-0">
<v-layout justify-start align-center>
<v-flex initial-xs px-2 py-3 class="handle minwdth-0" :title="$t('general.drag_for_reorder')">
<v-icon class="text--secondary text--lighten-3">$vuetify.icons.drag_indicator</v-icon>
</v-flex>
....
props: ['questions', 'disableDraggable'],
如何禁用可拖动功能?
我应该注意到
vue-draggable
(我正在使用的)据说与 SortableJs
具有相同的 api
最佳答案
应该是 :禁用 而不是 :禁用 .
<draggable v-model="copyOfQuestions" @end="$emit('updateQuestionsOrder', copyOfQuestions)" :options="{disabled : disableDraggable}">
引用:
https://github.com/SortableJS/Vue.Draggable/blob/17bdd4b8b2ab4f4df45dd76edf1afec864ec0936/example/debug-components/slot-example.vue
关于vuejs2 - vue-draggable 无法禁用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57179289/