This repository was archived by the owner on Jul 10, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +56
-1
lines changed Expand file tree Collapse file tree 4 files changed +56
-1
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,10 @@ export default class UsePlugin extends Vue {
2626 </script >
2727
2828<style lang="scss" scoped>
29+ h2 {
30+ color : crimson ;
31+ }
32+
2933.c {
3034 font-size : 20px ;
3135}
Original file line number Diff line number Diff line change 1+ <template lang="pug">
2+ div
3+ h1.title
4+ | user-agent
5+ hr
6+ h2 Nuxt.js 側で UA 判定した結果
7+ p {{ message }}
8+ hr
9+ h2 ブラウザ→①→ SSR サーバー→②→ API サーバー
10+ p {{ data }}
11+ </template >
12+
13+ <script lang="ts">
14+ import { Component , Vue } from ' nuxt-property-decorator'
15+ import axios from ' axios'
16+
17+ @Component
18+ export default class UserAgent extends Vue {
19+ message: string = ' '
20+ data: string = ' '
21+
22+ async asyncData(context ) {
23+ if (process .server ) {
24+ console .log (
25+ ' context.req.headers["user-agent"]:' ,
26+ context .req .headers [' user-agent' ]
27+ )
28+ } else {
29+ console .log (' navigator.userAgent:' , navigator .userAgent )
30+ }
31+
32+ // userAgent プロパティを context 内に追加します(context は `data` メソッドや `fetch` メソッド内で利用できます)
33+ context .userAgent = process .server
34+ ? context .req .headers [' user-agent' ]
35+ : navigator .userAgent
36+
37+ const { data } = await axios .get (` http://localhost:5000/headers ` )
38+
39+ return {
40+ message: context .userAgent ,
41+ data
42+ }
43+ }
44+ }
45+ </script >
46+
47+ <style lang="scss" scoped>
48+ h2 {
49+ color : crimson ;
50+ }
51+ </style >
File renamed without changes.
Original file line number Diff line number Diff line change 55export * from '@/utilities/cancelToken'
66export * from '@/utilities/auth'
77export * from '@/utilities/sleep'
8- export * from '@/utilities/dynamic-import '
8+ export * from '@/utilities/dynamicImport '
You can’t perform that action at this time.
0 commit comments