Browse Source

ssr 测试

zweizhao 7 years ago
parent
commit
474ed9aa4a
4 changed files with 39 additions and 4 deletions
  1. 1 1
      nuxt.config.js
  2. 10 2
      pages/index/vip.vue
  3. 3 1
      plugins/http.js
  4. 25 0
      server.js

+ 1 - 1
nuxt.config.js

@@ -57,7 +57,7 @@ module.exports = {
    * Proxy
    */
   proxy: [
-    ['/api', { target: 'https://dev.test.proginn.com/', changeOrigin: true }]
+    // ['/api', { target: 'https://dev.test.proginn.com/', changeOrigin: true }]
   ],
 
   /*

+ 10 - 2
pages/index/vip.vue

@@ -82,11 +82,18 @@
 </template>
 
 <script>
+// import http from '@/plugins/http'
+import axios from 'axios'
+
 export default {
+  async asyncData() {
+    let res = await axios.post('http://localhost:8080/api/getList')
+    return { vipList: res.data.data }
+  },
   data() {
     return {
       // 会员类型列表
-      vipList: [],
+      // vipList: [],
     }
   },
   computed: {
@@ -98,7 +105,8 @@ export default {
     }
   },
   mounted() {
-    this.getVIPList();
+    // this.getVIPList();
+    console.log(this.vipList)
   },
   methods: {
     /**

+ 3 - 1
plugins/http.js

@@ -89,4 +89,6 @@ const consoleFormat = obj => {
 
 Vue.prototype.$get = get
 Vue.prototype.$post = post
-Vue.prototype.$request = request
+Vue.prototype.$request = request
+
+export default { get, post, request }

File diff suppressed because it is too large
+ 25 - 0
server.js