md-virtual-repeater 使用 body 作为容器 [英] md-virtual-repeater using body as container

查看:26
本文介绍了md-virtual-repeater 使用 body 作为容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我计划使用 Angular Material 的虚拟重复来实现类似 Facebook 的功能,帖子无限滚动.

I am planning to use Angular Material's virtual repeat to achieve a Facebook like functionality where posts infinitely scroll.

是否可以在 HTML 文档的 body 标签上设置虚拟重复容器?

Is it possible to have the virtual repeat container on the body tag of the HTML document?

我不知道这将如何运作.我的 SPA 应用程序中有不同的路由,我需要根据页面是否使用无限滚动来动态添加/删除主体上的虚拟重复容器...

I don't see how that will work. I have different routes in my SPA app, I will need to add/remove the virtual repeat container on the body dynamically depending on if the page uses infinite scroll or not...

实现 md-virtual-repeat 以使 HTML 正文成为滚动容器的可行策略是什么?

What's a viable strategy for implementing md-virtual-repeat for having the HTML body to be the scroll container?

我没有遇到任何将容器放在 body 元素上的例子.

I have not come across any examples which put the container on the body element.

任何帮助将不胜感激.

推荐答案

经过一番折腾,我找到了答案.

After some fiddling around, I've found the answer.

答案其实很简单,如果您使用的是 Angular Material,请坚持使用 Angular Material.

The answer is actually very simple, if you're using Angular Material, stick to Angular Material.

我已经使用了所有布局(即容器、导航、sidenav),我发现 Angular Material 无论如何都不会使用浏览器的主体来滚动.所有内容都包含在它们的 container 元素中.只需在那里放一个 md-virtual-repeat-viewport 就可以了!

I've used all the layouts (i.e. container, nav, sidenav), I've found that Angular Material does not use the browser's body to scroll anyway. All content is contained in their container element. Simply put a md-virtual-repeat-viewport on there and you are good to go!

这篇关于md-virtual-repeater 使用 body 作为容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆