angular - Angular 8 如何将 $("#chat_panel").animate({ width: "toggle" }) 转换为打字稿?
问题描述
我需要将此 jquery 转换为 angular8
$("#chat_panel").animate({ width: "toggle" });
解决方案
Angular 和 jQuery 的主要区别在于访问 DOM 元素。当 jQuery 使用$
符号时,Angular 使用ViewChild
. 动画代码应该相同。
import { ViewChild, ElementRef } from '@angular/core';
@Component({
...
})
export class YourComponent {
@ViewChild('#chat_panel') chatPanel: ElementRef;
animateChatPanel(): void {
this.chatPanel.nativeElement.animate({
... // your animation code here
});
}
}
推荐阅读
- google-app-engine - 可以从谷歌云应用程序中恢复已删除的应用程序吗?
- django - Django / Wagtail:尝试添加新的子内容以呈现在模板上
- javascript - A* 算法 - Javascript:为什么我的算法找不到最短路径
- c# - 如何从 azure 作业批处理中的任务返回错误,以便可以重新激活任务?
- api - 如果应用程序支持多客户端登录,如何将客户端 ID 和客户端密码传递给应用程序端(移动应用程序、Web 应用程序)
- android - 我无法获取访问令牌来访问 Reddit API
- python - 打印语句在我的文件管理系统中没有响应
- xml - 使用powershell中的xpath选择xml中元素的值
- javascript - 角度应用程序在 angular.json 脚本中找不到依赖项
- azure - 托管在 .net 核心中的 azure 上的应用程序显示无效的 dateTime.utcNow