美文网首页
2018-09-26 作业(qq消息页面和联系人页面的制作)

2018-09-26 作业(qq消息页面和联系人页面的制作)

作者: LYH2312 | 来源:发表于2018-09-26 15:12 被阅读0次

1.消息页面 和联系人

<body>
   <div id='app'>
             <div class="app">
             <img src="img/666.jpg">
             <h2>李哈哈</h2>
       </div>
       <p class="ge">爱笑的人心事多</p>
       <router-link to='/news' class='nav'>消息</router-link>
       <router-link to='/contact' class='nav'>联系人</router-link>
       <router-link to='/zone' class='nav'>空间</router-link>
       
       <router-view></router-view>
   </div>
    <script src='js/vue.js'></script>
    <script src='js/vue-router.js'></script>
    <script src='js/axios.js'></script>
    <script>
        var News={
            template:`
              <div class="red">
                 <ul>
                    <li v-for="value in qqNews">
                       <img :src='value.pic'>
                       <div>
                          <p class='title'>
                            <span>{{value.title}}</span>
                            <span>{{new Date()|date}}</span>
                          </p>
                          <p class='text'>{{value.txt}}</p>
                       </div>
                    </li>
                 </ul>    
              </div>
            `,
            data:function(){
                return{
                    qqNews:null
                }
            },
            mounted:function(){
                var self=this;
                axios({
                    methos:'get',
                    url:'qq.json'
                }).then(function(resp){
                    console.log(resp)
                    self.qqNews=resp.data;
                }).catch(function(err){
                    console.log(err)
                })
            }
        }
        
        var Contact={
            template:`
              <div>
                 <ul class="green">
                     <li>
                        <router-link to='/contact/nice' class="a">好友</router-link>
                        <router-link to='/contact/tice' class="a">群聊</router-link>
                     </li>
                 </ul>
                 <router-view></router-view>
             </div>

          `
        }
        var Nice={
            template:`
            <div class="friend">
                <p><span>></span>新朋友</p>
                <p><span>></span>我的设备1/2</p>
                <p><span>></span>那年夏天24/32</p>
                <p><span>></span>久违三载42/58</p>
                <p><span>></span>似曾相识18/24</p>
                <p><span>></span>泊头职业学院44/52</p>
                <p><span>></span>公众号1/1</p>
                <p><span>></span>黑名单0/1</p>
            </div>

            `
        }

        var Tice={
            template:`
            <div>
                <p><span>></span>我的群聊10/20</p>
            </div>

            `
        }


        var Zone={
            template:`
              <div>
                <h1>这是空间页面</h1>
              </div>
          `
        }
        
       const routes=[
           {path:'/',component:News},
           {path:'/news',component:News},
           {path:'/contact',component:Contact,
               children:[
                   {path:'/',component:Nice},
                   {path:'nice',component:Nice},
                   {path:'tice',component:Tice}
               ]



           },
           {path:'/zone',component:Zone}
       ] 
        
       const router=new VueRouter({
           routes:routes,
           linkActiveClass:'active'
       }) 
        
 
       //过滤器:
         Vue.filter('date',function(data){
             return data.getHours()+":"+data.getMinutes();
         })
        new Vue({
            el:'#app',
            router:router
            
        })
    </script>

请求的后台json:

[
    {
        "pic":"img/1.jpg",
        "title":"马云",
        "txt":"我对钱不敢兴趣"
    },
    {
        "pic":"img/2.jpg",
        "title":"刘强东",
        "txt":"我不知道我媳妇好不好看!!!"
    },
    {
        "pic":"img/3.jpg",
        "title":"马化腾",
        "txt":"你们都赚了,就我赔了!!!"
    },
    {
        "pic":"img/4.jpg",
        "title":"大司马",
        "txt":"难受!!!"
    },
    {
        "pic":"img/5.jpg",
        "title":"卢本伟",
        "txt":"我和faker五五开"
    }
]

CSS样式

*{
    margin:0;
    padding:0;
    box-sizing:border-box;
}
a{
    text-decoration: none;
}
li{
    list-style: none;
}
#app{
    background: url("../img/333.jpg");
    overflow: hidden;
    width:312px;
    border:1px solid #000;
    margin:30px auto;
}
.app>img{
    margin-left: 10px;
    float: left;
    margin-top: 10px;
    width: 15%;
    border-radius: 50%;
}
.app>h2{
    color: white;
    line-height: 50px;
    height:50px;
    font-weight: normal;
}
 .ge{
     color: white;
    margin-left: 70px;
     margin-top: 5px;
}
.nav{
    line-height: 50px;
    display:inline-block;
    width:100px;
    text-align: center;
    font-size: 20px;
    color:white;
    height:50px;
}
.nav:hover{
    border-bottom: 3px solid darkgray;
    cursor: pointer;
    background: gainsboro;
}
.red ul>li{
    overflow: hidden;

    border-top:1px solid #EAF1FB;
    border-bottom:1px solid #EAF1FB;
}
.red ul>li:hover{
    cursor: pointer;
}
ul>li>img{
    margin-top: 5px;
    border-radius: 50%;
    float:left;
    margin-left: 8px;
    width:15%;
}
ul>li>div{
    float:left;
    margin-left:20px;
    
}

ul>li>div>p{
    height:33px;
    line-height: 33px;
}

.title>span:first-child{
    color:#000;
}
.title>span:nth-child(2){
     color:#7F7F7F; 
    margin-left:100px;
}

.text{
   color:#7F7F7F; 
}
.active{
    color: gold;
}
.green{
    margin-top: 10px;
    margin-left: 20px;
}
.a{
    color: white;
}
.friend p{
    color: white;
    height:60px;
    line-height: 60px;
    margin-left: 20px;
}
.friend p:hover{
    cursor: pointer;
    background:gainsboro;
}

联系人示例图如图所示:


2.png

消息如图所示:


1.png

相关文章

网友评论

      本文标题:2018-09-26 作业(qq消息页面和联系人页面的制作)

      本文链接:https://www.haomeiwen.com/subject/etgdoftx.html