This article shares a Vuejs component development tab component example for your reference. The specific content is as follows
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>index</title> <link rel="stylesheet" href="css/" > <script type="text/javascript" src="../lib/"></script> <script type="text/javascript" src="../lib/jquery-1.11."></script> <style> * { margin: 0; padding: 0; } #tabPanel .itemname { height: 40px; width: 180px; margin-bottom: 10px; } #tabPanel .itemcontent { height: 40px; width: 180px; } #tabPanel .addbtn { margin: 10px 0 0 95px; width: 185px; height: 40px; } #tabPanel .active { background: #eee; } #tabPanel { height: 340px; width: 500px; margin: 100px auto; } #tabPanel .tab { height: 40px; background: #ccc; margin-top: 10px; } #tabPanel .tab ul li { list-style: none; float: left; width: 80px; height: 40px; text-align: center; line-height: 40px; } #tabPanel .content { height: 300px; width: 500px; background: #eee; } </style> </head> <body> <div > <my-tab></my-tab> <my-tab></my-tab> </div> <!--Component templates--> <script type="text/template" > <div > <label>Add slider name:<input type="text" v-model="tabItem" class="itemname"></label><br> <label>Add slider content:<input type="text" v-model="tabContent" class="itemcontent"></label><br> <input type="button" value="Add Options" @click="addItem()" class="addbtn"> <div class="tab"> <ul> <li v-for="(value, index) in tabs" v-bind:class="{active: index == num }" @mouseover="toggle(index)" @dblclick="del(index)">{{value}}</li> </ul> </div> <div class="content"> <div class="box" v-for="(value, index) in tabContents" v-show="index == num" contenteditable="true" @blur="editContent(index,value)">{{value+index}}</div> </div> </div> </script> <!--Component templates--> </body> </html> <script> var vue = new Vue({ el: "#tabItem", data: { }, components: { 'my-tab': { template: '#tab', data: function() { return { tabs: ["First item", "The Second Item"], tabContents: ["First Content", "The Second Content"], num: 0, tabItem: "", tabContent: "" } }, methods: { //Switch slider toggle: function(index) { = index; }, //Add slider addItem: function() { if ( == "" || == "") { alert("Fill in the full name and content"); } else { (); (); } }, //Double click to delete the slider del: function(index) { (index, 1); (index, 1) }, //Edit Options Content editContent: function(index, value) { [index] = value; (); } } } } }); </script>
If you still want to learn in depth, you can click on two exciting topics:Summary of how to operate javascript tab Summary of how to operate jquery tab
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.