How to use toView in the applet?
In the applet toView
is an attribute, which is used to specify id
the position of a component with attributes when the page is scrolled. The specific usage method is as follows:
- Add an attribute on the component that needs to be scrolled to
id
, for example:
<view id="target">我是需要滚动到的组件</view>
scroll-into-view
Add a property on the component that needs to trigger scrolling , and set its value toid
the value of the component that needs to be scrolled to, for example:
<button type="primary" scroll-into-view="target">点击我滚动到目标组件</button>
The attribute here scroll-into-view
can be set to the value id
of any component with attribute id
3. scroll-view
Add scroll-into-view
the attribute to the component on the page, and set its value to the id
value of the component that needs to be scrolled to, for example:
<scroll-view scroll-into-view="target">
<!-- 这里是需要滚动的内容 -->
</scroll-view>
In this way, when the component that triggers scrolling is clicked, the page will scroll to id
the position of the component with the corresponding property.
It should be noted that if the component that needs to be scrolled is inside the component, then the property scroll-view
needs to be set on the component, not the internal component. In addition, if the component that needs to be scrolled is outside the component, then the property needs to be set on the root node of the page.scroll-into-view
scroll-view
scroll-view
scroll-into-view