• vue 横向导航滚动 光标移动动画



    <template> <div class="nav_wrapper"> <div ref="navContainer" class="nav_container"> <div class="nav_item" v-on:click="onClick(item)" v-for="(item,index) in Navs" :key="index"> {{item.title}} </div> <div class="nav_footer_cursor" :style="{ Num, left:Left }" ></div> </div> </div> </template>

      

    <script>
    import {mapState} from "vuex";
    export default {
        data(){
            return{
                Left:"10px",
                Num:"64px"
            }
        },
        computed:mapState({
            Navs:"Navs"//这是拿到的导航列表
        }),
        methods:{
            onClick(obj){
                let num=window.event.target.offsetWidth;
                let positionNum=window.event.target.offsetLeft;
                // window.console.log(positionNum)
                this.Num=num+"px";
                this.Left=positionNum+"px";
                this.$store.dispatch("SortGoods",obj)
            }
        }
    }
    </script>
    

      

    <style scoped>
    .nav_wrapper
    {
        100%;
        height:40px;
        margin-top:64px;
    }
    .nav_item
    {
        100px;
        height:40px;
        text-align: center;
        white-space: nowrap;
        padding:0 10px;
    }
    .nav_container::-webkit-scrollbar{
        display: none;
    }
    .nav_container
    {
        100%;
        display: flex;
        position: relative;
        overflow: scroll;
        white-space: nowrap;
    }
    .nav_footer_cursor
    {
        100%;
        height:3px;
        border-radius:3px;
        background: red;
        position: absolute;
        margin-top:20px;
        transition: all 0.3s linear 0.1s;
    }
    </style>
    

      

  • 相关阅读:
    [POJ1743]Musical Theme
    ubuntu qq
    Separate code and data contexts: an architectural approach to virtual text sharing
    Python3发送post请求,自动记住cookie
    python 异步协程
    豆瓣爬虫
    pandas 使用
    房天下爬虫
    计算英文文章词频的两种方法
    LOW版统计词频
  • 原文地址:https://www.cnblogs.com/xiaobu-wu/p/12851761.html
Copyright © 2020-2023  润新知