V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
loveuloveme
V2EX  ›  问与答

如何让 v-for 额外渲染的数据往下显示? 目前这一段代码,当数据超过一屏后,点击 Show More,新的内容会把原来的内容往上撑,而不是往下

  •  
  •   loveuloveme · Oct 5, 2020 · 935 views
    This topic created in 2029 days ago, the information mentioned may be changed or developed.
    <div id="ttt" style="padding-bottom:100px;border: 1px solid green">
            <div v-for="(comment, index) in comments">
                <div>
                    <p v-text="comment"></p>
                </div>
    
            </div>
            <button class="btn" @click="showMore">
                Show More
            </button>
        </div>
    
    <script>
        new Vue({
            el: '#ttt',
            data: {
                comments: ['tom', 'jack' ,'lily'],
            },
            methods: {
                showMore() {
                            this.comments = this.comments.concat(['mary', 'jessica'])
                        }
            },
        });
        </script>
    
    1 replies    2020-10-05 23:38:24 +08:00
    IvanLi127
        1
    IvanLi127  
       Oct 5, 2020 via Android
    插入前记下滚动条位置,插完后滚立马回来。 css 有一个属性能控制,overflow-anchor 。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   6086 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 173ms · UTC 02:36 · PVG 10:36 · LAX 19:36 · JFK 22:36
    ♥ Do have faith in what you're doing.