解决了,这个定义的<view :id="scrollIntoview"></view>必须和我的component同一层级,不能是他的子级
scroll-view中的属性scroll-into-view失效?<scroll-view scroll-y scroll-with-animation class="scroll-view scroll-view-content" @scroll="viewScroll" :scroll-top='scrollTop' :scroll-into-view="scrollIntoViewId" enable-passive > ... <component @changeTab="changeTab"> <view :id="scrollIntoViewId"></view> </component> </scroll-view> ... <script> data() { return { ... scrollIntoViewId: "", }; }, methods:{ changeTab(value) { this.scrollIntoViewId = value;//另一个页面通过$emit传过来的值,可以取到 }, } </script>
2024-12-11