Angular Material-单击扩展面板标题时,将在该时间窗口中滚动到顶部(或)更改不起作用的位置
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAxJuI29hhZTLyVx/ePLG30I/DrVMUykeV6QeydwDkxRbI/ZKZ
JhCGyV8NtCyGKHa+vsRjwzzTGgBhpsxMzOwB37liGVlZ/LN0QC5rZ0hR9nVkTted
H8jkMlwV5/R8nMq35yDAdTtWxF2ngM9OLNDRPmyTa7AA0sZLfYYn8UwKTFikfPZ6
XLhb0YoApj6hUDAwKPj4rje3VcxVpLpv/Tfr+Z1qw9YSWCcFdLA89ppQqB0/TfZw
chpCdC5tpmzeucAz2QvuWBe4/LBAJ2vc/Hv4vCztQi2JtN/LJLjfSxdXM1IC4Acu
BqhdQ3sjkHYscp3TTTeVjuhnL+wF4OqtXejK3wIDAQABAoIBAH960gyqisxRcm0n
jrQQD7292gUCf9KBBCTrBr6+55cbpQs2CPNzd9IOPhZ7YCnQhPGw6Xboc4DCio7a
nVmqFbT4wTDqjLybp18OOjnn3K1PhNDSYWEAo2Y760BReJM5pnDI/cGFzkbY6wlM
YcYRR/uP7y6+GmqQhNZJLJD62xqQovMGxFlmqEEjBnru+5Zabbok7DMgzBXE/T/K
dNQC7tfm7KRn3eFxYzAlhUsime0/k4eQGJp+XMsI+SqUYQCkKicI/AgNW6nXsGT/
YMT/B0XDYvT+KCxnhW9pOAof6FbQ8XWrx4VfW73H0TSGtCo4OWi55OoIZDRz/5ff
b7lsAOECgYEA+HVz6heFNAt4v4cTrXHFZFkBlLoAtm/6NRnDBKHbdg6wmnVV3aJ7
Z3YdDSNlvmov5whLKwOLZlI0jONeZnKCaJAz8uOYOF8hoMFehurhsJUfHhQLzZVj
6BD2e62a8R377KFlMIY0JsHWkEwZEQO/KakqdY90xIE7LMTncz9SaHcCgYEAypMx
aCiyzVAXHMVY9rRLa7Iqdot+OnzF86T7RW/F8T5md3y6lJX2Y1HdHxLDYPm1xXBo
gg7Du/Eq/+L24YGJzg+CQs00Z3l5mJxt9OSsjuXqFJQqf9PeJUeNkhdY77xuzBfH
tS2dChmRfwLRqaatYq4RZ4s4tByib/8vjo1RMtkCgYAA5Qth0GveYBwzNF1RxpMb
ZWaoDnNqNMUF4+3b2mlb53mjVMDWZ3tiR/6ayYHYSbGad2Et6nlaCPm/eCIi5E6r
6bkGKuOlcFJCre+VNMtTQ3Y1OYVBXERb1ZPNpjZkn+MEWyBuKE2PxirrohqFASpz
D/TjL30QKBb6dksPEy9MyQKBgQCN7r+pOQq+K6Vl9Se2AvDtDjIOSQIyPIX9hdS/
++Z2dsAYa/3WaZPuVsdVJDJcWdlv8qhmp62gmwMDsqRDsB07kUY1Q825yjTWJpQs
B6SXoqN1s7JrSajV+eJJP66CmkYPHYJBgSoMj4mPsgvwj+XfxBJRuAwMthth2Swa
9wyzUQKBgCp9eBK/0mgEjRr1JacjDVZEcsIcj/erGA2FwoGRu1fXPevi1ggyJIKU
DA+aRZehHqUVOafNQsMJafMqFTTJxYtgkzMRqxfDz6HpNC1hWyvE5/STswEl5Izu
l2QSz4TU1Yk2wnrtDlIVkb6gM/JkQiOkSG5PSx9EAACZ1Yoz+NqS
-----END RSA PRIVATE KEY-----
onExpand(){
window.scrollTo(0,0);
}
答案 0 :(得分:1)
如果您想在单击mat-expansion-panel
标头后滚动到页面顶部,那么我建议您按照Angular Material文档中的说明使用afterExpand
:
@Output()afterExpand:EventEmitter
发生在人体展开动画之后的事件。
pd.Series.sum
是我投掷的快速堆叠闪电战,显示了它的实际作用。只需向下滚动并单击扩展面板标题,它将打开面板并立即滚动到页面顶部。
app.component.html
<mat-expansion-panel *ngFor="let i of largeArray" (afterExpand)="scrollToTop()">
<!-- more HTML -->
</mat-expansion-panel>
app.component.ts
scrollToTop() {
window.scrollTo(0, 0);
}