console
Vue.component('v-steps',{
props: {
items:Array,
index: {
type: Number,
default: 0
}
},
data() {
return {
active: this.index
}
},
computed: {
},
methods: {
onClick(index) {
this.active = index;
this.$emit('change', index);
console.log(index);
}
},
template:"#steps"
})
var Main = {
data(){
return{
items: [
{
title: "步骤1",
description: "描述性文字1"
},
{
title: "步骤2",
description: "描述性文字1"
},
{
title: "步骤3",
description: "描述性文字1"
},
{
title: "步骤4",
description: "描述性文字1"
}
]
};
},
methods: {}
}
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')
<template id="steps">
<el-steps
:active="active"
align-center>
<el-step
v-for="(item, index) in items"
:key="index"
:title="item.title"
:description="item.description"
@click.native="onClick(index)"
></el-step>
</el-steps>
</template>
<div id="app">
<v-steps :items="items" :index="2"></v-steps>
</div>