zoukankan      html  css  js  c++  java
  • yb课堂 前端项目通用底部选项卡 CommonsFooter 《三十六》

    学会看cube-UI文档,并掌握cube-tab-bar开发

    前端需求分析

    • 底部导航
    • 首页Banner
    • 首页视频列表
    • 视频详情模块
    • 注册模块
    • 登陆模块
    • 个人信息模块
    • 下单模块
    • 订单列表模块

    文档地址:https://didi.github.io/cube-ui/#/zh-CN/docs/quick-start

    template开发

      在components下创建CommonFooter.vue

    <template>
      <div class="tab">
        <cube-tab-bar v-model="selectedLabelSlots" @click="changHandler">
          <cube-tab
            v-for="(item) in tabs"
            :icon="item.icon"
            :label="item.label"
            :key="item.path"
            :value="item.path"
          ></cube-tab>
        </cube-tab-bar>
      </div>
    </template>
    <script>
    export default {
      data() {
        return {
          selectedLabelSlots: "/",
          tabs: [
            {
              label: "首页",
              icon: "cubeic-home",
              path: "/"
            },
            {
              label: "我的订单",
              icon: "cubeic-like",
              path: "/order"
            },
            {
              label: "个人中心",
              icon: "cubeic-person",
              path: "/personal"
            }
          ]
        };
      }
    };
    </script>

    vue-router常见API

    • router.path:获取当前的路由
    • router.go(n):这个方法的参数是一个整数,表示在history记录中向前或者后退多少步,类似window.history.go(n)方法
    • router.push(path):导航到不同的path路径,这个方法会向history栈添加一个新的记录,所以当前用户点击浏览器后退按钮时,则回到之前的URL

    完整CommonFooter.vue

    <template>
      <div class="tab">
        <cube-tab-bar v-model="selectedLabelSlots" @click="changHandler">
          <cube-tab
            v-for="(item) in tabs"
            :icon="item.icon"
            :label="item.label"
            :key="item.path"
            :value="item.path"
          ></cube-tab>
        </cube-tab-bar>
      </div>
    </template>
    <script>
    export default {
      data() {
        return {
          selectedLabelSlots: "/",
          tabs: [
            {
              label: "首页",
              icon: "cubeic-home",
              path: "/"
            },
            {
              label: "我的订单",
              icon: "cubeic-like",
              path: "/order"
            },
            {
              label: "个人中心",
              icon: "cubeic-person",
              path: "/personal"
            }
          ]
        };
      },
      methods: {
        changHandler(path) {
          //this.this.$route.path:当前路径
          if (path !== this.this.$route.path) {
            this.$routerouter.push(path);
          }
        }
      },
      created() {
        //默认路由选择器,比如刷新页面,需要重新进到当前路由
        this.selectedLabelSlots = this.this.$route.path;
      }
    };
    </script>
    <!--SCSS是⼀种CSS预处理语⾔, scoped 是指这个scss样式 只作⽤于当前组件-->
    <style lang="scss" scoped>
    .tab {
      position: fixed;
      bottom: 0;
      z-index: 999;
      background-color: #fff;
       100%;
      border-top: 1px solid rgba($color: #000000, $alpha: 0.1);
    }
    .cube-tab_active {
      color: #3bb149;
    }
    </style>
    作者:陈彦斌

    个性签名:没有学不会的技术,只有不学习的人!
    联系方式:543210188(WeChat/QQ),推荐WeChat
  • 相关阅读:
    MyEclipse:详细使用教程
    JDK安装与配置详细图文教程
    windows下python3.6版本安装pygame
    windows下如何下载并安装Python
    python的 del 函数是删对象还是删引用
    python strip()函数的用法
    python的垃圾回收机制
    python中的sort方法
    python中del函数的垃圾回收
    两个数交换
  • 原文地址:https://www.cnblogs.com/chenyanbin/p/13340071.html
Copyright © 2011-2022 走看看