You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
shop-pc/layouts/default.vue

62 lines
1.2 KiB

3 years ago
<!--
* @Author: ch
* @Date: 2022-05-04 17:56:39
* @LastEditors: ch
2 years ago
* @LastEditTime: 2022-05-31 16:52:40
3 years ago
* @Description: file content
-->
<template>
<div class="layout">
<BsLogin :visible.sync="loginVisible" />
<Header :is-sticky="isSticky" />
<div class="layout-content">
<Nuxt />
</div>
2 years ago
<Footer />
</div>
3 years ago
</template>
<script>
import BsLogin from "@/components/BsLogin.vue";
import Header from "./module/header/index.vue";
import Footer from "./module/footer/index.vue";
3 years ago
export default {
name: "Layout",
components: { Header, Footer, BsLogin },
data() {
return {
isSticky: false,
};
},
computed: {
loginVisible: {
get() {
return this.$store.state.loginVisible;
},
set(val) {
this.$store.commit("setLoginVisible", val);
},
},
},
mounted() {
// 监听滚动事件
window.addEventListener("scroll", this.scrollEventMethod);
},
destroyed() {
window.removeEventListener("scroll", this.scrollEventMethod);
},
methods: {
scrollEventMethod() {
this.isSticky = window.scrollY > 300;
},
},
};
</script>
<style lang="scss" scoped>
.layout {
.layout-content {
min-height: calc(100vh - 400px);
}
}
</style>