How to use toView in the applet

How to use toView in the applet?

In the applet toViewis an attribute, which is used to specify idthe position of a component with attributes when the page is scrolled. The specific usage method is as follows:

  1. Add an attribute on the component that needs to be scrolled to id, for example:
  <view id="target">我是需要滚动到的组件</view>
  1. scroll-into-viewAdd a property on the component that needs to trigger scrolling , and set its value to idthe 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-viewcan be set to the value idof any component with attribute id3. scroll-viewAdd scroll-into-viewthe attribute to the component on the page, and set its value to the idvalue 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 idthe 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-viewneeds 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-viewscroll-viewscroll-viewscroll-into-view

Guess you like

Origin blog.csdn.net/u011024243/article/details/130664709