Skip to content

Commit

Permalink
Fix v-model not working
Browse files Browse the repository at this point in the history
  • Loading branch information
cristijora committed Jul 30, 2017
1 parent 49358cb commit e4d2f6f
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 38 deletions.
30 changes: 12 additions & 18 deletions dev/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,16 @@
<div>
<vue-tabs class="card" @on-error="handleError"
v-model="tabName">
<!--<template slot="tab" scope="props">
<li :class="{active:props.tab.active}" >
<a href="" @click.prevent="props.clickHandler(props.index)" style="border-radius:50%">
{{props.tab.title}}
</a>
</li>
</template>-->
<v-tab v-for="(re, index) in reList"
:key="re.name"
:title="re.name"
<v-tab v-for="(tab, index) in tabList"
:key="tab.name"
:title="tab.name"
icon="ti-user">
{{re.name}}
{{tab.name}}
</v-tab>
</vue-tabs>
<button @click="reList.push({name:'test'})">Add more!</button>
<button @click="reList.splice(0,1)">Remove first</button>
<button @click="tabList.push({name:'test'})">Add more!</button>
<button @click="tabList.splice(0,1)">Remove first</button>
<button @click="goToSecondTab">Go to second tab</button>
</div>
</template>

Expand All @@ -27,17 +21,17 @@
name: 'app',
data(){
return {
reList : [],
tabName: 'name2'
tabList : [{name:'name1'},{name:'name2'},{name:'name3'}],
tabName: 'name1'
}
},
methods: {
handleError(error){
this.error = error
},
goToSecondTab(){
this.tabName='name2'
}
},
mounted () {
this.reList = [{name:'name1'},{name:'name2'},{name:'name3'}]
}
}
</script>
Expand Down
12 changes: 6 additions & 6 deletions dist/vue-tabs.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ var VueTabs = {
}
return [];
},
findTabAndActivate: function findTabAndActivate(tabName) {
var indexToActivate = this.tabs.findIndex(function (tab) {
return tab.title === tabName;
findTabAndActivate: function findTabAndActivate(tabNameOrIndex) {
var indexToActivate = this.tabs.findIndex(function (tab, index) {
return tab.title === tabNameOrIndex || index === tabNameOrIndex;
});
if (indexToActivate != -1) {
this.changeTab(this.activeTabIndex, indexToActivate);
Expand Down Expand Up @@ -237,10 +237,10 @@ var VueTabs = {
if (newList.length > 0 && this.value) {
this.findTabAndActivate(this.value);
}
},
value: function value(newVal) {
this.findTabAndActivate(newVal);
}
},
value: function value(newVal) {
this.findTabAndActivate(newVal);
}
};

Expand Down
12 changes: 6 additions & 6 deletions dist/vue-tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ var VueTabs = {
}
return [];
},
findTabAndActivate: function findTabAndActivate(tabName) {
var indexToActivate = this.tabs.findIndex(function (tab) {
return tab.title === tabName;
findTabAndActivate: function findTabAndActivate(tabNameOrIndex) {
var indexToActivate = this.tabs.findIndex(function (tab, index) {
return tab.title === tabNameOrIndex || index === tabNameOrIndex;
});
if (indexToActivate != -1) {
this.changeTab(this.activeTabIndex, indexToActivate);
Expand Down Expand Up @@ -239,10 +239,10 @@ var VueTabs = {
if (newList.length > 0 && this.value) {
this.findTabAndActivate(this.value);
}
},
value: function value(newVal) {
this.findTabAndActivate(newVal);
}
},
value: function value(newVal) {
this.findTabAndActivate(newVal);
}
};

Expand Down
2 changes: 1 addition & 1 deletion dist/vue-tabs.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e4d2f6f

Please sign in to comment.