Browse Source

main layout iframe时去除头部

yangc 8 years ago
parent
commit
4a8b2b17ad
3 changed files with 19 additions and 3 deletions
  1. 9 1
      layouts/default.vue
  2. 1 1
      layouts/main.vue
  3. 9 1
      layouts/shop.vue

+ 9 - 1
layouts/default.vue

@@ -1,6 +1,6 @@
 <template>
   <div id="app">
-    <header-view></header-view>
+    <header-view v-if="!isInFrame"></header-view>
     <nuxt/>
     <footer-view></footer-view>
     <right-bar></right-bar>
@@ -11,6 +11,11 @@
 
   export default {
     name: 'app',
+    data () {
+      return {
+        isInFrame: false
+      }
+    },
     components: {
       HeaderView: Header,
       FooterView: Footer,
@@ -21,6 +26,9 @@
         title: this.title
       }
     },
+    mounted () {
+      this.isInFrame = self !== top
+    },
     computed: {
       title () {
         let path = this.$route.path

+ 1 - 1
layouts/main.vue

@@ -35,7 +35,7 @@
       }
     },
     mounted () {
-      this.isInFrame = window.location.href !== parent.location.href
+      this.isInFrame = self !== top
     },
     computed: {
       title () {

+ 9 - 1
layouts/shop.vue

@@ -1,6 +1,6 @@
 <template>
   <div id="main">
-    <header-view></header-view>
+    <header-view v-if="!isInFrame"></header-view>
     <store-header/>
     <store-title/>
     <nuxt/>
@@ -17,6 +17,11 @@
   }
   export default {
     name: 'shop',
+    data () {
+      return {
+        isInFrame: false
+      }
+    },
     components: {
       HeaderView: Header,
       FooterView: Footer,
@@ -24,6 +29,9 @@
       StoreHeader,
       StoreTitle
     },
+    mounted () {
+      this.isInFrame = self !== top
+    },
     head () {
       return {
         title: this.title,