日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

1分钟入门angular动画效果animations,敲简单滴哟~~☺

發(fā)布時間:2023/11/27 生活经验 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 1分钟入门angular动画效果animations,敲简单滴哟~~☺ 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

?運行代碼創(chuàng)建component

ng g c animate-test

?然后在app.module.ts做如下引入

?分別是下面兩行,自行引入

import {BrowserAnimationsModule} from '@angular/platform-browser/animations';//注意這個很重要BrowserAnimationsModule,//注意這個很關鍵,沒有引入動不起來

接下來傻瓜式拷貝代碼?

?animate-test.component.html

<button (click)="toggle()">{{yellowOrGreen ? '你黃了!':'你被綠了!'}}</button>
<div [@openClose]="yellowOrGreen ? 'yellow' : 'green'" ><p>{{yellowOrGreen ? '你黃了!':'你被綠了!'}}</p>
</div>

animate-test.component.ts

import {Component, OnInit} from '@angular/core';
import {trigger, state, style, animate, transition} from '@angular/animations';@Component({selector: 'app-animate-test',templateUrl: './animate-test.component.html',styleUrls: ['./animate-test.component.css'],animations: [trigger('openClose', [state('yellow', style({height: '50px', color: 'black', backgroundColor: 'yellow'})),state('green', style({height: '100px', color: 'white', fontSize: '40px', fontWeight: 'bold', backgroundColor: 'green'})),transition('yellow=>green', [animate('0.3s')]),transition('green=>yellow', [animate('0.5s')]),// transition('yellow <=> green', [animate('1s')]) //雙箭頭可以指定兩個狀態(tài)互相轉(zhuǎn)場])]
})
export class AnimateTestComponent implements OnInit {public yellowOrGreen = true;ngOnInit() {}public toggle() {this.yellowOrGreen = !this.yellowOrGreen;}
}

然后別忘了在app-routing.module.ts路由里面加入這個組件頁面喲~

import {AnimateTestComponent} from "./components/animate-test/animate-test.component";{path: 'animate-test',component: AnimateTestComponent,//同步加載},

然后ng?start --open跑起來吧親~

注意訪問地址大概是http://localhost:4200/animate-test

點擊按鈕之后就

總結

以上是生活随笔為你收集整理的1分钟入门angular动画效果animations,敲简单滴哟~~☺的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。