码迷,mamicode.com
首页 > 其他好文 > 详细

页面流动条

时间:2020-06-18 21:11:59      阅读:50      评论:0      收藏:0      [点我收藏+]

标签:scrolltop   oct   meta   char   files   ati   position   for   attr   

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>ssc_web</title>
    <script src="https://cdn.bootcss.com/vue/2.6.4/vue.min.js"></script>
</head>
<body>
<div id="app">
    <div id="scrollTree" style="height: 200px;width: 300px;overflow: auto">
        <div style="height: 5000px;position: relative">
            <div v-for="item in data" :style="{top:(item-1)*50+‘px‘}"
                 style="height: 50px;position: absolute;width: 100%">
                {{item}}
            </div>
        </div>
    </div>
</div>
<!-- built files will be auto injected -->
</body>
<script>
    var vm = new Vue({
        el: ‘#app‘,
        data: function () {
            return {data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]};
        },
        mounted: function () {
            document.getElementById(‘scrollTree‘).onscroll = function (e) {
                let i = parseInt((e.target.scrollTop + 250) / 50);
                if (i > 95) i = 95;
                vm.data = [i - 4, i - 3, i - 2, i - 1, i, i + 1, i + 2, i + 3, i + 4, i + 5];
            };
        }
    });
</script>
</html>

页面流动条

标签:scrolltop   oct   meta   char   files   ati   position   for   attr   

原文地址:https://www.cnblogs.com/xiaoxiao95/p/13159635.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!