国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

vue實現tab切換外加樣式切換方法

2024-05-06 15:20:37
字體:
來源:轉載
供稿:網友

實例如下所示:

<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title> <style>  * {   margin: 0;   padding: 0;   list-style: none  }  #app {   width: 504px;   height: 300px;   margin: 100px auto;   border: 1px solid #000;  }  ul {   overflow: hidden;  }  li {   width: 100px;   height: 50px;   float: left;   text-align: center;   line-height: 50px;   border-bottom: 1px solid #000;   border-right: 1px solid #000;  }  li:nth-child(5) {   border-right: none;  }  .cur {   height: 51px;   background: blue;   border-bottom: none;  } </style></head><body><div id="app"> <ul>  <li v-for="(num,index) in nums" :class="{cur:iscur==index}" @click="iscur = index,tab('text'+(index+1))">   {{num.t}}  </li> </ul> <div class="box">  <component :is='currentView' keep-alive></component> </div></div><script src="vue.js"></script><script> const text1 = Vue.component('text1', {template: `<div><h1>Text111111111111</h1></div>`}); const text2 = Vue.component('text2', {template: `<div><h1>Text222222222222</h1></div>`}); const text3 = Vue.component('text3', {template: `<div><h1>Text333333333333</h1></div>`}); const text4 = Vue.component('text4', {template: `<div><h1>Text444444444444</h1></div>`}); const text5 = Vue.component('text5', {template: `<div><h1>Text555555555555</h1></div>`}); var vm = new Vue({  el: "#app",  data: {   currentView: text1,   nums: [{t: "text1"}, {t: "text2"}, {t: "text3"}, {t: "text4"}, {t: "text5"}],   iscur: 0  },  methods: {   tab(tabText){    this.currentView = tabText;   }  } })</script></body></html>

以上這篇vue實現tab切換外加樣式切換方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持錯新站長站。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 缙云县| 古田县| 竹溪县| 德清县| 通渭县| 淳安县| 绥滨县| 沙湾县| 沁水县| 吉隆县| 桃园市| 庆安县| 达拉特旗| 二连浩特市| 荥经县| 枣庄市| 西吉县| 海林市| 东辽县| 沈阳市| 海兴县| 淮北市| 象山县| 贡嘎县| 饶河县| 渝中区| 泰兴市| 杂多县| 吉安县| 大厂| 崇文区| 醴陵市| 惠州市| 禄丰县| 长阳| 海门市| 丹寨县| 黄梅县| 武川县| 八宿县| 蒙自县|