本文實(shí)例為大家分享了angular6開發(fā)steps步驟條組件的實(shí)現(xiàn)代碼,供大家參考,具體內(nèi)容如下
做網(wǎng)站、成都網(wǎng)站建設(shè)服務(wù)團(tuán)隊(duì)是一支充滿著熱情的團(tuán)隊(duì),執(zhí)著、敏銳、追求更好,是創(chuàng)新互聯(lián)的標(biāo)準(zhǔn)與要求,同時(shí)竭誠為客戶提供服務(wù)是我們的理念。創(chuàng)新互聯(lián)建站把每個(gè)網(wǎng)站當(dāng)做一個(gè)產(chǎn)品來開發(fā),精雕細(xì)琢,追求一名工匠心中的細(xì)致,我們更用心!
1.先展示步驟條效果
2.使用angular命令快速創(chuàng)建組件
ng g c component/steps
創(chuàng)建的組件在component文件夾下面
打開steps.component.ts文件,可以看到selector的值是app-steps
import { Component, OnInit} from '@angular/core'; @Component({ selector: 'app-steps', templateUrl: './steps.component.html', styleUrls: ['./steps.component.css'] }) export class StepsComponent implements OnInit { constructor() { } ngOnInit() { } }
3.代碼
steps.component.html
active}">active}"> {{item.tips}}
{{item.title}}{{item.description}}
steps.component.ts
import { Component, OnInit, Input } from '@angular/core'; //引入Input @Component({ selector: 'app-steps', templateUrl: './steps.component.html', styleUrls: ['./steps.component.css'] }) export class StepsComponent implements OnInit { @Input() stepsData:any; @Input() active:string; constructor() { } ngOnInit() { console.log(!!!this.active) if(!!!this.active){ this.active="1"; } } }
steps.component.css
.steps ul{ display: flex; } li{ width: 100%; text-align: center; } .lineUl{ padding: 0px 10%; margin-bottom: 5px; } .liWidth{ width: 20px; } .stepsIcon{ display: flex; } .radioSelect { box-sizing: border-box; display: inline-block; border-radius: 100%; border: 1px solid #26a2ff; position: relative; width: 20px; height: 20px; vertical-align: middle; background-color: #26a2ff; } .radioSelect::after { border: 2px solid transparent; border-left: 0; border-top: 0; content: ' '; top: 3px; left: 6px; position: absolute; width: 4px; height: 8px; border-color: #fff; -webkit-transform: rotate(45deg) scale(1); transform: rotate(45deg) scale(1); -webkit-transition: -webkit-transform 0.2s; transition: -webkit-transform 0.2s; transition: transform 0.2s; transition: transform 0.2s, -webkit-transform 0.2s; } .radioSelectDisabled { background-color: #d9d9d9; border-color: #ccc; } .line{ display: block; flex: 1; height: 16px; border-bottom: 1px solid#26a2ff; margin-top: -5px; font-size: 12px; color: #26a2ff; } .lineDefaule{ border-bottom: 1px solid#d9d9d9; } .title{ font-size: 14px; } .description{ font-size: 12px; }
4在項(xiàng)目中引用創(chuàng)建的組件
public stepsData:any = [ { title:'步驟1', description:'描述文件' }, { title:'步驟2', description:'描述文件' }, { title:'步驟3', description:'描述文件', tips:'待開獎(jiǎng)' }, { title:'步驟4', description:'描述文件' } ]; //stepsData:步驟條參數(shù) //active:設(shè)置當(dāng)前激活步驟,默認(rèn)為1
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。