zoukankan      html  css  js  c++  java
  • angular2实现图片轮播

     1 import { Component, OnInit } from '@angular/core';
     2 
     3 @Component({
     4     moduleId: module.id,
     5     selector: 'my-app',
     6     template: `
     7     <div class="bannerContainer">
     8       <ul class="bannerPicList"> 
     9         <li [class.active]="currentPic==0"> <img src="app/images/black-hat.jpg"/></li>
    10         <li [class.active]="currentPic==1"> <img src="app/images/black-shoes.jpg"/></li>
    11         <li [class.active]="currentPic==2"> <img src="app/images/blue-jacket.jpg"/></li>
    12       </ul>
    13       <ul class="bannerBtnList"> 
    14         <li><span class="picBtn" (click)="changebanner(0)"></span></li>
    15         <li><span class="picBtn" (click)="changebanner(1)"></span></li>
    16         <li><span class="picBtn" (click)="changebanner(2)"></span></li>
    17       </ul>
    18     </div>
    19     `,
    20     styles: [`
    21         .bannerPicList li{
    22             display: none;
    23         }
    24         .bannerPicList li.active{
    25             display: block;
    26         }
    27         .bannerContainer .bannerBtnList {
    28             position: absolute;
    29             top: 360px;
    30             left: 116px;
    31           
    32         }
    33         .bannerContainer .bannerBtnList li {
    34             float: left;
    35             margin: 0 5px;
    36             list-style-type:none;
    37         }
    38         .bannerContainer .bannerBtnList span.picBtn {
    39             margin: 20px;
    40             height: 10px;
    41              10px;
    42             background-color: #ddd;
    43             display: block;
    44             border-radius: 5px;
    45             cursor: pointer;
    46         }
    47     `]
    48 })
    49 export class AppComponent implements OnInit {
    50     currentPic = 0;
    51     constructor() {
    52         setInterval(() => {
    53             let id = (this.currentPic + 1) % 3;
    54             this.currentPic = id;
    55         },3000)
    56     }
    57 
    58     changebanner(id) {
    59         console.log(id)
    60         this.currentPic = id;
    61     }
    62     ngOnInit() { }
    63 }
  • 相关阅读:
    JQ_浏览器窗口改变触发
    5. 通过PHP反序列化进行远程代码执行
    2. 文件包含(150)
    1. md5 collision(50)
    4.xpath注入详解
    2.HTTP头注入
    1.5 xss漏洞修复
    1.4 DVWA亲测XSS漏洞
    1.如何绕过WAF(Web应用防火墙)
    1.3 xss原理分析与剖析(4)
  • 原文地址:https://www.cnblogs.com/cjxhd/p/6047852.html
Copyright © 2011-2022 走看看