xinfeng 6 년 전
부모
커밋
97cd7d3f1c
1개의 변경된 파일14개의 추가작업 그리고 9개의 파일을 삭제
  1. 14 9
      pages/user/collect_article/_id/_type.vue

+ 14 - 9
pages/user/collect_article/_id/_type.vue

@@ -171,17 +171,22 @@
   export default {
     layout: "opacity_header",
     async asyncData({ $axios, params, req, app }) {
-      console.log("********req********", req)
-      const { headers: { host } = {}, url } = req || {}
-      //拼接canonical
-      let canonical = ""
-      if (host.indexOf('local') !== -1) {
-        canonical = 'http://' + host + url
-      } else {
-        canonical = 'https://' + host + url
+      if (process.server) {
+        const { headers: { host } = {}, url } = req || {}
+        //拼接canonical
+        let canonical = ""
+        if (host.indexOf('local') !== -1) {
+          canonical = 'http://' + host + url
+        } else {
+          canonical = 'https://' + host + url
+        }
+        return {
+          nowUrl: canonical,
+          mobile: app.$deviceType.isMobile()
+        }
       }
+
       return {
-        nowUrl: canonical,
         mobile: app.$deviceType.isMobile()
       }
     },