叶子小小的,碧绿碧绿的,花儿小小的,好可爱。紫红色的玫瑰花在风中翩翩起舞,玫瑰花树枝上还有调皮又可爱的小刺,你可要当心哦!你看,那个大仙人球旁围着8个小仙人球,好像一家人聚在一起,多欢快呀!
本文为大家分享了vuejs组件开发之手风琴菜单组件实例,供大家参考,具体内容如下
小图标是引入font-awesome字体图标库绘制的。效果如下图所示:
代码:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>index</title> <link rel="stylesheet" rel="nofollow noopener noreferrer" href="css/font-awesome.min.css"> <link rel="stylesheet" rel="nofollow noopener noreferrer" href="css/index.css"> <script type="text/javascript" src="../lib/vue.min.js"></script> <script type="text/javascript" src="../lib/jquery-1.11.3.min.js"></script> <style> * { margin: 0; padding: 0; } body { padding-top: 100px; } #tabPanel { width: 120px; height: auto; margin: 0 auto; } #tabPanel .item .sildermun ul li { height: 40px; line-height: 40px; list-style: none; } #tabPanel .item .sildermun ul li:hover { background: #ccc; } #tabPanel .item .menutitle { height: 40px; line-height: 40px; text-align: center; background: #ccc; } #tabPanel .item .sildermun { text-align: center; background: #eee; } </style> </head> <body> <div id="tabItem"> <slider-item></slider-item> <slider-item></slider-item> <slider-item></slider-item> <slider-item></slider-item> </div> <!--组件模板,也可以使用template标签方式引入模板--> <template id="tab"> <div id="tabPanel"> <div class="item"> <div class="menutitle" @click="toggle()"><i class="icon-th-list"></i>{{parentItem}}</div> <div class="sildermun" v-show="status"> <ul> <li v-for="(index,v) in childItems"><i class="icon-star"></i>{{v+index}}</li> </ul> </div> </div> </div> </div> </template> <!--组件模板,也可以使用template标签方式引入模板--> </body> </html>
<script> var vue = new Vue({ el: "#tabItem", data: { }, components: { 'slider-item': { template: '#tab', data: function() { return { status: false, parentItem: "父级菜单", childItems: ["子级菜单", "子级菜单", "子级菜单", "子级菜单"] } }, methods: { //切换滑块 toggle: function() { this.status = !this.status; } } } } }); </script>
本文Vue.javascript手风琴菜单组件开发实例到此结束。峡江两岸的山直起直落,高得让人头晕。谢谢大家支持!