慢慢慢慢6666
慢慢慢慢6666
  • 发布:2021-07-13 12:05
  • 更新:2021-07-13 17:06
  • 阅读:965

scroll-into-view滚动到id位置无效

分类:uni-app
<template>  
    <view class="content">  
        <scroll-view scroll-y="ture" style="width:80%; max-height: 20vh;background-color: #C8C7CC;color: #DD524D;"  
            scroll-into-view="demo"  
        >  
            <view class=""><text>{{value}}</text></view>  
            <view id="demo"></view>  
        </scroll-view>  
    </view>  
</template>  

<script>  
    export default {  
        data() {  
            return {  
                goTimer: null,  
                i: 0,  
                value: ''  
            }  
        },  
        created() {  
            this.init();  
        },  
        beforeDestroy() {  
            if(this.goTimer){  
                clearInterval(this.goTimer)  
            }  
        },  
        methods:{  
            init() {  
                var _that = this  
                this.goTimer = setInterval(function(){  
                        _that.go()  
                },400)  
            },  
            go() {  
                this.value += '请另行在小程序';  
            }  

        }  
    }  
</script>  

<style lang="scss" scoped>  
    .content {  
        margin: 0;  
        padding: 10px;  
        width: 100%;  
        height: 90vh;  
    }  
</style>  
2021-07-13 12:05 负责人:无 分享
已邀请:
慢慢慢慢6666

慢慢慢慢6666 (作者) - 慢慢、

go() {  
                this.value += '请另行在小程序';  
                uni.pageScrollTo({  
                    selector:"typeId",  
                    // duration:0, //默认不需要过渡动画(手机运行必须?)  
                    // scrollTop: 9999,  
                });  
            }

啥情况

慢慢慢慢6666

慢慢慢慢6666 (作者) - 慢慢、

微信小程序没效果

DCloud_UNI_HT

DCloud_UNI_HT

在 onReady 生命周期执行 ,onLoad 里元素还没渲染好

  • 慢慢慢慢6666 (作者)

    也不行

    2021-07-14 22:53

  • 慢慢慢慢6666 (作者)

    组件的话mounted内也不行


    onReady(){  
    this.init();
    },

    2021-07-14 22:54

  • 慢慢慢慢6666 (作者)

    ?

    2021-07-14 22:55

  • DCloud_UNI_HT

    你的 scroll-into-view="demo" 压根就没变过 ,可能不会生效 ,把 demo 这个变成变量,动态赋值,代码参考


    <template>  
    <view class="content">
    <scroll-view scroll-y="ture" style="width:80%; max-height: 20vh;background-color: #C8C7CC;color: #DD524D;"
    :scroll-into-view="demo">
    <view ><text>{{value}}</text></view>
    <view id="demo"></view>
    </scroll-view>
    </view>
    </template>

    <script>
    export default {
    data() {
    return {
    goTimer: null,
    i: 0,
    value: '',
    demo:''
    }
    },
    created() {
    this.init();
    },
    beforeDestroy() {
    if (this.goTimer) {
    clearInterval(this.goTimer)
    }
    },
    methods: {
    init() {
    var _that = this
    this.goTimer = setInterval(function() {
    _that.demo = ''
    _that.go()
    }, 1000)
    },
    go() {
    this.value += '请另行在小程序请另行在小程序请另行在小程序';
    this.$nextTick(()=>{
    this.demo = 'demo'
    })
    }

    }
    }
    </script>

    <style lang="scss" scoped>
    .content {
    margin: 0;
    padding: 10px;
    width: 100%;
    height: 90vh;
    }
    </style>

    2021-07-15 10:17

  • 慢慢慢慢6666 (作者)

    回复 DCloud_UNI_HT: 我去 大佬啊,我以为局部滚动边加载边滚动没法实现了呢,关注了

    2021-07-16 14:31

该问题目前已经被锁定, 无法添加新回复