listboxs.vue
1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<style>
</style>
<template>
<!-- :class="[show?openclass:'',showfocus?focusclass:'']" -->
<li :class="[show?openclass:'',showfocus?focusclass:'']"
:data-id="indexid">
<span v-on:click="toggle()">{{listobj.name}}</span>
<ul v-if="listobj.children" v-show="listobj.show">
<listboxs v-for="item in listobj.children"
:listobj.sync="item" :openclass="openclass" :focus="focus"
:focusclass="focusclass"
:indexid="indexid+$index" ></listboxs>
</ul>
</li>
</template>
<script>
module.exports={
props:{
listobj:{
type:Object,default:{}
},openclass:{
type:String,default:''
},focus:{
type:String,default:''
},focusclass:{
type:String,default:''
},indexid:{
type:String,default:''
}
},
methods:{
toggle:function(){
var a = Object.assign({}, this.listobj, {
show:!this.listobj.show })
this.$set('listobj',a);
this.$dispatch('listboxcall',this.listobj);
this.$dispatch('setfocus',this.indexid);
}
},computed:{
show:function(){
return this.listobj.show && this.listobj.children
},showfocus :function(){
return this.indexid==this.focus;
}
},ready:function(){
}
}
</script>