vue 基础 实例

<!DOCTYPE html >
< html lang= "zh-cn" >
   < head >
     < meta http-equiv= "Content-Type" content= "text/html; charset=utf-8" />
< title ></ title >
     < style >
       ul {
         padding: 0;
         margin: 0;
         list-style: none;
      }
       .wrap {
         width: 384px;
         height: 707px;
         background: url( ./imgs/bg1.png) no-repeat center center;
         margin: 0 auto;
         position: relative;
      }

       .list {
         width: 280px;
         position: absolute;
         left: 46px;
         top: 64px;
      }
       .list h2 {
         height: 48px;
         font: 14px/ 48px arial;
         color: #fff;
         background: rgba( 0, 0, 0, .8);
         box-sizing: border-box;
         padding-left: 10px;
      }
       .list h2:nth-of-type( 1 ){
         margin: 0;
      }
       .list h2.active {
         background: rgba( 221, 84, 111, .8)
      }
       .list span {
         width: 0;
         height: 0;
         display: inline-block;
         border: 6px dashed rgba( 0, 0, 0, 0);
         border-left: 6px solid rgba( 255, 255, 255, 1);
         margin-right: 10px;
         position: relative;
         top: 1px;
      }
       .list span.active {
         width: 0;
         height: 0;
         display: inline-block;
         border: 6px dashed rgba( 0, 0, 0, 0);
         border-top: 6px solid rgba( 255, 255, 255, 1);
         position: relative;
         top: 4px;
      }
       .list ul {
         background: #000000;
         color: #fff;
         display: none;
      }
       .list li {
         height: 40px;
         font: 14px/ 40px "微软雅黑";
         box-sizing: border-box;
         padding-left: 34px;
      }
       .list .item {
         margin: 10px 0;
      }

       .list .active h2{
         background: rgba( 221, 84, 111, .8)
      }
       .list .active ul{
         display: block;
      }
     < / style >
     < script src= "../vue.js" > < / script >
     < script >
       var qqData = [
       {
       title: '好友',
       list: [
       {
       subTitle: '1'
       },
       {
       subTitle: '2'
       },
       {
       subTitle: '3'
       }
       ]
       },
       {
       title: '同事',
       list: [
      
            {
       subTitle: '1111'
            },
           
       ]
       }
      ]

     < / script >
   </ head >
/vue
   < body >
     < div class= "wrap" id= "app" >
     < div class= "list" >
     < div
        class= "item"
        v-for= "item,index in qqData"
       : class= "{active: index === currentIndex }"
     >
        < h2 @ click= "tab(index)" >< span ></ span >{{item.title}} </ h2 >
        < ul >
        < li v-for= "option in item.list" >{{option.subTitle}} </ li >
        </ ul >
     </ div >
     </ div >
     </ div >
     < script >
       new Vue({
         el: '#app',
         data: {
           qqData: qqData,
           currentIndex: ''
        },
         methods: {
           tab ( index) {
             this. currentIndex = this. currentIndex === index? '' : index;
          }
        }
      })
     < / script >
   </ body >
</ html >

< template >
< div class= "wrap" >
< div class= "list" >
< h2 >< span ></ span >我的好友 </ h2 >
< ul >
< li >eeeeeeee e </ li >
</ ul >
< h2 >< span ></ span >企业好友 </ h2 >
< ul >
< li > luke </ li >
< li > selina </ li >
< li > mathew </ li >
</ ul >
< h2 >< span ></ span >黑名单 </ h2 >
< ul >
< li > chenqingyue </ li >
< li > wjq </ li >
</ ul >
</ div >
</ div >
</ template >

< script >
export default {
}
</ script >
< style scoped >

.wrap {
   width: 384px;
   height: 707px;
   /*background: url(./imgs/bg1.png) no-repeat center center;*/
   margin: 0 auto;
   position: relative;
}

.list {
   width: 280px;
   position: absolute;
   left: 46px;
   top: 64px;
}
.list h2 {
   height: 48px;
   font: 14px/ 48px arial;
   color: #fff;
   background: rgba( 0, 0, 0, .8);
   box-sizing: border-box;
   padding-left: 10px;
   margin-top: 10px;
}
.list h2:nth-of-type( 1 ){
   margin: 0;
}
.list h2.active {
   background: rgba( 221, 84, 111, .8)
}
.list span {
   width: 0;
   height: 0;
   display: inline-block;
   border: 6px dashed rgba( 0, 0, 0, 0);
   border-left: 6px solid rgba( 255, 255, 255, 1);
   margin-right: 10px;
   position: relative;
   top: 1px;
}
.list span.active {
   width: 0;
   height: 0;
   display: inline-block;
   border: 6px dashed rgba( 0, 0, 0, 0);
   border-top: 6px solid rgba( 255, 255, 255, 1);
   position: relative;
   top: 4px;
}
.list ul {
   background: #000000;
   color: #fff;
   display: none;
}
.list li {
   height: 40px;
   font: 14px/ 40px "微软雅黑";
   box-sizing: border-box;
   padding-left: 34px;
}
.list li.active {
   background: rgba( 255, 255, 255, .4);
}

.list li.selected {
   background: rgba( 221, 84, 111, .6);
}
</ style >





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值