scrollIntoView对于 slot 的元素无效
发布于 4 年前 作者 zgu 944 次浏览 来自 问答
<scroll-view scroll-y="{{true}}" scroll-with-animation="{{true}}" style="{{anonymousState__temp2}}" scroll-into-view="{{scrollId}}" bindscroll="anonymousFunc1">
    <slot></slot>
</scroll-view>

右侧没有任何滚动

试过了,如果不用 slot 直接写是可以滚动的

3 回复

的确是这样的。在指定 scroll-into-view 的 id 的时候,只能指定当前组件自身包含的节点,通过 slot 插进来的节点不算。

其他组件使用 id 值的属性也有类似的特征,比如 label 组件的 for 属性。

在包一层view,不然slot插槽会认为插入了很多个,或者开启组件的多插槽,然后命名。

回到顶部