Skip to content

Commit

Permalink
fix(TabItem): 修复 Vue Router tag prop is deprecated 警告
Browse files Browse the repository at this point in the history
  • Loading branch information
bhuh12 committed Dec 9, 2021
1 parent fb3c0fe commit d969248
Showing 1 changed file with 29 additions and 14 deletions.
43 changes: 29 additions & 14 deletions lib/components/TabItem.js
Expand Up @@ -101,9 +101,15 @@ export default {
// 拖拽
onDragStart(e) {
this.onDragSort = this.$tabs.onDragSort = true
e.dataTransfer.dropEffect = 'move'
dragSortData = TRANSFER_PREFIX + this.index
e.dataTransfer.setData('text', dragSortData)
e.dataTransfer.effectAllowed = 'move'
},

// 拖拽悬浮
onDragOver(e) {
this.isDragOver = true
e.dataTransfer.dropEffect = 'move'
},

// 拖拽结束
Expand Down Expand Up @@ -135,20 +141,29 @@ export default {
const { default: slot = this.slotDefault } = this.$tabs.$scopedSlots

return (
<router-link
tag="li"
class={this.classList}
<RouterLink
custom
to={this.to}
draggable={this.$tabs.dragsort}
vOn:dragstart_native={this.onDragStart}
vOn:dragend_native={this.onDragEnd}
vOn:dragover_native_prevent={() => (this.isDragOver = true)}
vOn:dragleave_native_prevent={() => (this.isDragOver = false)}
vOn:drop_native_stop_prevent={this.onDrop}
vOn:click_native_middle={() => this.closable && this.close()}
>
{slot(this)}
</router-link>
scopedSlots={{
default: ({ navigate }) => {
return (
<li
class={this.classList}
draggable={this.$tabs.dragsort}
vOn:click={navigate}
vOn:dragstart={this.onDragStart}
vOn:dragend={this.onDragEnd}
vOn:dragover_prevent={this.onDragOver}
vOn:dragleave_prevent={() => (this.isDragOver = false)}
vOn:drop_stop_prevent={this.onDrop}
vOn:click_middle={() => this.closable && this.close()}
>
{slot(this)}
</li>
)
}
}}
></RouterLink>
)
}
}

0 comments on commit d969248

Please sign in to comment.