-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
207 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<template> | ||
<div class="content"> | ||
<vue-tabs-chrome ref="tab" v-model="tab" :tabs="tabs" insert-to-after /> | ||
<div class="btns"> | ||
<button @click="addTab">New Tab</button> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
data () { | ||
return { | ||
tab: 'google', | ||
tabs: [ | ||
{ | ||
label: 'google', | ||
key: 'google', | ||
favico: require('../assets/google.jpg') | ||
}, | ||
{ | ||
label: 'facebook', | ||
key: 'facebook', | ||
favico: require('../assets/fb.jpg') | ||
} | ||
] | ||
} | ||
}, | ||
methods: { | ||
addTab () { | ||
let item = 'tab' + Date.now() | ||
let newTabs = [ | ||
{ | ||
label: 'New Tab', | ||
key: item | ||
} | ||
] | ||
this.$refs.tab.addTab(...newTabs) | ||
this.tab = item | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<template> | ||
<div class="content"> | ||
<vue-tabs-chrome | ||
ref="tab" | ||
v-model="tab" | ||
:tabs="tabs" | ||
@swap="handleSwap" | ||
@remove="handleRemove" | ||
/> | ||
<div class="btns"> | ||
<button @click="addTab">New Tab</button> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
data () { | ||
return { | ||
tab: 'google', | ||
tabs: [ | ||
{ | ||
label: 'google', | ||
key: 'google', | ||
favico: require('../assets/google.jpg') | ||
}, | ||
{ | ||
label: 'facebook', | ||
key: 'facebook', | ||
favico: require('../assets/fb.jpg') | ||
} | ||
] | ||
} | ||
}, | ||
beforeMount () { | ||
this.load() | ||
}, | ||
methods: { | ||
addTab () { | ||
let name = prompt('input tab name') | ||
if (!name) return | ||
let item = 'tab' + Date.now() | ||
let newTabs = [ | ||
{ | ||
label: name, | ||
key: item | ||
} | ||
] | ||
this.$refs.tab.addTab(...newTabs) | ||
this.tab = item | ||
this.save() | ||
}, | ||
load () { | ||
let tabs = localStorage.getItem('VUE_TABS_CHROME') | ||
if (tabs) { | ||
this.tabs = JSON.parse(tabs) | ||
} | ||
}, | ||
save () { | ||
localStorage.setItem('VUE_TABS_CHROME', JSON.stringify(this.$refs.tab.getTabs())) | ||
}, | ||
handleSwap (tab, targetTab) { | ||
console.log(tab, targetTab) | ||
this.save() | ||
}, | ||
handleRemove (tab, index) { | ||
console.log(tab, index) | ||
this.save() | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters