반응형
드래그 가능한 Vuetify 확장 패널
저는 Vuejs에 처음 와서 Vuetify를 하고 stackoverflow도 합니다.나는 끌 수 있는 확장 패널을 vuetify로 만드는 작업을 받았다.나는 많은 노력을 했지만 아무 것도 잘 되지 않았다.다음은 제가 팔로우한 몇 가지 문제점과 github 소스 코드입니다.
1) https://github.com/SortableJS/Vue.Draggable
2) 기능성 Vuejs 2 정렬 가능한 v-expansion-panels - 구글 검색 부탁드립니다
하지만 난 아무 것도 잘 되지 않았어.누가 나 좀 도와줄래?내가 참조할 수 있는 만지작거리나 코드펜은?
이 vuetify와 vue.js를 cdn으로만 사용하여 컴포넌트를 Import할 수 없습니다.
잘 부탁드립니다.
HTML(프로토타입):
<div id="app">
<v-app id="inspire">
<v-data-table
v-bind:headers="headers"
:items="items"
hide-actions
class="elevation-1"
ref="sortableTable"
>
<template slot="items" slot-scope="props">
<tr class="sortableRow" :key="itemKey(props.item)"> <!-- NOTE: You'll need a unique ID, that is specific to the given item, for the key. Not providing a unique key that's bound to the item object will break drag and drop sorting. The itemKey method will return a uid for a given object using WeakMap. You could just use a property in the object with a unique value, like "props.item.name" in this case, but often getting a unique value from the object's properties can be difficult, like when adding new rows, or when the unique field is open to editing, etc. -->
<td class="px-1" style="width: 0.1%">
<v-btn style="cursor: move" icon class="sortHandle"><v-icon>drag_handle</v-icon></v-btn>
</td>
<td>{{ props.item.name }}</td>
<td class="text-xs-right">{{ props.item.calories }}</td>
<td class="text-xs-right">{{ props.item.fat }}</td>
<td class="text-xs-right">{{ props.item.carbs }}</td>
<td class="text-xs-right">{{ props.item.protein }}</td>
<td class="text-xs-right">{{ props.item.sodium }}</td>
<td class="text-xs-right">{{ props.item.calcium }}</td>
<td class="text-xs-right">{{ props.item.iron }}</td>
</tr>
</template>
</v-data-table>
</v-app>
</div>
JS 프로토타입:
new Vue({
el: '#app',
mounted () {
/* eslint-disable no-new */
new Sortable(
this.$refs.sortableTable.$el.getElementsByTagName('tbody')[0],
{
draggable: '.sortableRow',
handle: '.sortHandle',
onEnd: this.dragReorder
}
)
},
methods: {
dragReorder ({oldIndex, newIndex}) {
const movedItem = this.items.splice(oldIndex, 1)[0]
this.items.splice(newIndex, 0, movedItem)
},
itemKey (item) {
if (!this.itemKeys.has(item)) this.itemKeys.set(item, ++this.currentItemKey)
return this.itemKeys.get(item)
}
},
data () {
return {
itemKeys: new WeakMap(),
currentItemKey: 0,
headers: [
{
sortable: false
},
{
text: 'Dessert (100g serving)',
align: 'left',
sortable: false,
value: 'name'
},
{ text: 'Calories', value: 'calories', sortable: false },
{ text: 'Fat (g)', value: 'fat', sortable: false },
{ text: 'Carbs (g)', value: 'carbs', sortable: false },
{ text: 'Protein (g)', value: 'protein', sortable: false },
{ text: 'Sodium (mg)', value: 'sodium', sortable: false },
{ text: 'Calcium (%)', value: 'calcium', sortable: false },
{ text: 'Iron (%)', value: 'iron', sortable: false }
],
items: [
{
value: false,
name: 'Frozen Yogurt',
calories: 159,
fat: 6.0,
carbs: 24,
protein: 4.0,
sodium: 87,
calcium: '14%',
iron: '1%'
},
{
value: false,
name: 'Ice cream sandwich',
calories: 237,
fat: 9.0,
carbs: 37,
protein: 4.3,
sodium: 129,
calcium: '8%',
iron: '1%'
},
{
value: false,
name: 'Eclair',
calories: 262,
fat: 16.0,
carbs: 23,
protein: 6.0,
sodium: 337,
calcium: '6%',
iron: '7%'
},
{
value: false,
name: 'Cupcake',
calories: 305,
fat: 3.7,
carbs: 67,
protein: 4.3,
sodium: 413,
calcium: '3%',
iron: '8%'
},
{
value: false,
name: 'Gingerbread',
calories: 356,
fat: 16.0,
carbs: 49,
protein: 3.9,
sodium: 327,
calcium: '7%',
iron: '16%'
},
{
value: false,
name: 'Jelly bean',
calories: 375,
fat: 0.0,
carbs: 94,
protein: 0.0,
sodium: 50,
calcium: '0%',
iron: '0%'
},
{
value: false,
name: 'Lollipop',
calories: 392,
fat: 0.2,
carbs: 98,
protein: 0,
sodium: 38,
calcium: '0%',
iron: '2%'
},
{
value: false,
name: 'Honeycomb',
calories: 408,
fat: 3.2,
carbs: 87,
protein: 6.5,
sodium: 562,
calcium: '0%',
iron: '45%'
},
{
value: false,
name: 'Donut',
calories: 452,
fat: 25.0,
carbs: 51,
protein: 4.9,
sodium: 326,
calcium: '2%',
iron: '22%'
},
{
value: false,
name: 'KitKat',
calories: 518,
fat: 26.0,
carbs: 65,
protein: 7,
sodium: 54,
calcium: '12%',
iron: '6%'
}
]
}
}
})
언급URL : https://stackoverflow.com/questions/52720313/vuetify-expansion-panel-with-draggable
반응형
'programing' 카테고리의 다른 글
Java에서 HashMap 객체와 Map 객체의 차이점은 무엇입니까? (0) | 2022.06.21 |
---|---|
Android - 소프트 키보드를 프로그래밍 방식으로 숨기기/표시 (0) | 2022.06.21 |
정렬을 수행하기 위한 C 라이브러리 함수 (0) | 2022.06.21 |
오류: IntelliJ IDE에서 기본 클래스를 찾거나 로드할 수 없습니다. (0) | 2022.06.21 |
vue 어플리케이션에서 Paypal 서브스크립션을 구현하려면 어떻게 해야 합니까? (0) | 2022.06.21 |