$ anchorScroll in Ionic 2?滚动到带ID的元素 [英] $anchorScroll in Ionic 2? Scroll to element with ID

查看:233
本文介绍了$ anchorScroll in Ionic 2?滚动到带ID的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从Angular 1.x到离子2 / Angular2的任何方式做$ anchorScroll?

any way to do $anchorScroll in ionic 2/Angular2 as of Angular 1.x?

尝试滚动到页面上的元素。
我试过像ng2-page-scroll
https:// github。 com / Nolanus / ng2-page-scroll

Trying to scroll to an element on page. I tried something like ng2-page-scroll https://github.com/Nolanus/ng2-page-scroll

不确定我是否正确行事,我按照教程进行操作并收到错误:

not sure if i m doing it right, i followed through the tutorial and got error:

ParseError: 'import' and 'export' may appear only with 'sourceType: module'

我认为这不再适用于最新的离子2版本。
只希望有更简单的方法,任何解决方法吗?

I think that doesnt work with the latest ionic 2 release anymore. only wish there's an easier way of doing it, any work around?

推荐答案

我遇到了同样的情况,我想在每次点击按钮时滚动到下一页/元素的位置。

I was in the same situation, where I wanted to scroll to the next page/element for each click of a button.

我看了你提到的相同选项,我发现在离子滑片中( http://ionicframework.com/docs/v2/api/components/slides/Slides/ ),您可以将方向设置为垂直 ,这对我有用。

I looked at the same options you mentioned, and I found that in ion-slides (http://ionicframework.com/docs/v2/api/components/slides/Slides/), you can set the direction to 'vertical', which did the trick for me.

不知道它是否可以帮助您使用案例。

Don't know if it can help your use case.

否则,您可以查看内容,和scrollTo函数。
http://ionicframework.com/docs/v2/api/组件/内容/内容/

Otherwise, you can look into Content, and the scrollTo function. http://ionicframework.com/docs/v2/api/components/content/Content/

这篇关于$ anchorScroll in Ionic 2?滚动到带ID的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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