zoukankan      html  css  js  c++  java
  • Vue实现选项卡效果




    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>选项卡</title>
        <script src="../vue.js"></script>
        <style>
    *{
     padding: 0px;
      margin: 0px;
     }
     
     .wrapper{
      margin: 50px auto;
      450px;
     height:400px;
      border: 1px solid #000;
      }
      .nav{
      list-style: none;
      450px;
      height: 80px;
      font-size: 0px;
      }
     .nav li{
      148px;
     height:80px;
      font-size: 16px;
      border: 1px solid #000;
     display: inline-block;
      text-align: center;
     line-height: 80px
     }
     .content div{
    450px;
    height: 320px;
    text-align: center;
      line-height: 320px;
     background:pink;
     }
      .primary{
     background:red
     }
     .default{
     background:#aaa;
     }
     </style>
    </head>
     

    <body>
      <div id='app'>
      <div class='wrapper'>
     <ul class='nav'>
      <li v-for='(item,index) in list'
     @click='sel(index)'
    :class='index==selIndex?"primary":"default"'
     >{{item.title}}</li>
     </ul>
      <div class='content'>
      <div v-for='(item,index) in list'
      v-if='index==selIndex'
      >{{item.info}}</div>

         </div>
        </div>
      </div>



    <script>
      new Vue({
        el:'#app',
        data:{
          list:[{title:'荷花',info:'小荷才露尖尖角,早有蜻蜓立上头'},
                {title:'菊花',info:'采菊东篱下,悠然见南山'},
                 {title:'梅花',info:'墙角数枝梅,凌寒独自开'}],
           selIndex:0
         },
        methods: {
         sel(index){
             this.selIndex=index
            }
        },
     })

    </script>
    </body>
    </html>

  • 相关阅读:
    PAT1064(上)分析部分
    网络支付极其简单的体会
    L3,please send me a card
    PAT1008
    里氏转换
    数组遍历问题
    注册登录界面(简陋版)
    表单事件,onblur,onfocus,焦点
    复制所有链接,全选,反选
    剪切板
  • 原文地址:https://www.cnblogs.com/class1/p/11011928.html
Copyright © 2011-2022 走看看