|
@@ -0,0 +1,130 @@
|
|
|
|
+<template>
|
|
|
|
+ <div class="Learn">
|
|
|
|
+ <div class="ban" ref="ban">
|
|
|
|
+ <img src="@/assets/img/bannerL.png" alt="" />
|
|
|
|
+ </div>
|
|
|
|
+ <div class="rowAll" :class="{ curSorll: menaSon }">
|
|
|
|
+ <div
|
|
|
|
+ @click="cutTab(item.path)"
|
|
|
|
+ class="row"
|
|
|
|
+ v-for="(item, index) in tabData"
|
|
|
|
+ :key="index"
|
|
|
|
+ :class="{ active: idMate === item.path }"
|
|
|
|
+ >
|
|
|
|
+ {{ item.name }}
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <Router-view />
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+export default {
|
|
|
|
+ name: "Learn",
|
|
|
|
+ components: {},
|
|
|
|
+ data() {
|
|
|
|
+ //这里存放数据
|
|
|
|
+ return {
|
|
|
|
+ menaSon: false,
|
|
|
|
+ idMate: "/Layout/Learn/Students",
|
|
|
|
+ tabData: [
|
|
|
|
+ { name: "Students", path: "/Layout/Learn/Students" },
|
|
|
|
+ { name: "Adults", path: "/Layout/Learn/Adults" },
|
|
|
|
+ { name: "Families & Children", path: "/Layout/Learn/Families" },
|
|
|
|
+ ],
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ //监听属性 类似于data概念
|
|
|
|
+ computed: {},
|
|
|
|
+ //监控data中的数据变化
|
|
|
|
+ watch: {
|
|
|
|
+ $route() {
|
|
|
|
+ this.idMate = this.$route.path;
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ //方法集合
|
|
|
|
+ methods: {
|
|
|
|
+ cutTab(path) {
|
|
|
|
+ this.$router.push(path).catch(() => {});
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ //生命周期 - 创建完成(可以访问当前this实例)
|
|
|
|
+ created() {
|
|
|
|
+ this.idMate = this.$route.path;
|
|
|
|
+ },
|
|
|
|
+ //生命周期 - 挂载完成(可以访问DOM元素)
|
|
|
|
+ mounted() {
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ // 获取顶部元素ban的高度
|
|
|
|
+ let banDom = this.$refs.ban;
|
|
|
|
+ // 获取滚动的总元素
|
|
|
|
+ let scrollDom = document.querySelector(".Layout");
|
|
|
|
+ // 获取顶部固定栏
|
|
|
|
+ let LayoutTop = document.querySelector(".Layout .top");
|
|
|
|
+ scrollDom.onscroll = () => {
|
|
|
|
+ if (scrollDom.scrollTop > banDom.offsetHeight) {
|
|
|
|
+ LayoutTop.style.display = "none";
|
|
|
|
+ this.menaSon = true;
|
|
|
|
+ } else {
|
|
|
|
+ LayoutTop.style.display = "flex";
|
|
|
|
+ this.menaSon = false;
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ }, 0);
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ beforeCreate() {}, //生命周期 - 创建之前
|
|
|
|
+ beforeMount() {}, //生命周期 - 挂载之前
|
|
|
|
+ beforeUpdate() {}, //生命周期 - 更新之前
|
|
|
|
+ updated() {}, //生命周期 - 更新之后
|
|
|
|
+ beforeDestroy() {}, //生命周期 - 销毁之前
|
|
|
|
+ destroyed() {
|
|
|
|
+ // 获取滚动的总元素,删除滚动事件
|
|
|
|
+ let scrollDom = document.querySelector(".Layout");
|
|
|
|
+ scrollDom.onscroll = null;
|
|
|
|
+ // 获取顶部固定栏
|
|
|
|
+ let LayoutTop = document.querySelector(".Layout .top");
|
|
|
|
+ LayoutTop.style.display = "flex";
|
|
|
|
+ }, //生命周期 - 销毁完成
|
|
|
|
+ activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
|
|
|
|
+};
|
|
|
|
+</script>
|
|
|
|
+<style lang='less' scoped>
|
|
|
|
+.Learn {
|
|
|
|
+ width: 100%;
|
|
|
|
+ background-color: #f7f6f3;
|
|
|
|
+ .ban {
|
|
|
|
+ position: relative;
|
|
|
|
+ width: 100%;
|
|
|
|
+ & > img {
|
|
|
|
+ width: 100%;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ .rowAll {
|
|
|
|
+ width: 100%;
|
|
|
|
+ height: 70px;
|
|
|
|
+ display: flex;
|
|
|
|
+ justify-content: space-around;
|
|
|
|
+ align-items: center;
|
|
|
|
+ background-color: #f7f6f3;
|
|
|
|
+ .row {
|
|
|
|
+ font-size: 16px;
|
|
|
|
+ height: 30px;
|
|
|
|
+ line-height: 30px;
|
|
|
|
+ padding: 0 8px;
|
|
|
|
+ }
|
|
|
|
+ .active {
|
|
|
|
+ background-color: #c1aa7b;
|
|
|
|
+ border-radius: 15px;
|
|
|
|
+ color: #fff;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ .curSorll {
|
|
|
|
+ z-index: 99;
|
|
|
|
+ position: fixed;
|
|
|
|
+ top: 0;
|
|
|
|
+ left: 0;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+</style>
|