• 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>

  • 相关阅读:
    全局变量-静态变量
    System.Web.Optimization 找不到引用,教你如何解决?
    CSS text-decoration 属性
    HTML 5 <span> 标签
    [VS]
    C# 条件表达式max=(a>b)?a:b;含义
    vs 2017 Integrated Security 为sspi 含义
    Visual studio 利用Nuget 控制台安装已经下载好的插件
    使用INTERSECT运算符
    Oracle DB 使用子查询来解决查询
  • 原文地址:https://www.cnblogs.com/class1/p/11011928.html
Copyright © 2020-2023  润新知