質問編集履歴

3

詳細を追加

2018/12/07 11:58

投稿

Matt
Matt

スコア41

test CHANGED
File without changes
test CHANGED
@@ -43,3 +43,121 @@
43
43
  </style>
44
44
 
45
45
  ```
46
+
47
+
48
+
49
+ # 追記:試したことの詳細
50
+
51
+ 1.プロジェクトを作成
52
+
53
+ ```
54
+
55
+ $ vue init webpack test
56
+
57
+ ? Project name test
58
+
59
+ ? Project description A Vue.js project
60
+
61
+ ? Author
62
+
63
+ ? Vue build standalone
64
+
65
+ ? Install vue-router? Yes
66
+
67
+ ? Use ESLint to lint your code? No
68
+
69
+ ? Set up unit tests No
70
+
71
+ ? Setup e2e tests with Nightwatch? No
72
+
73
+ ? Should we run `npm install` for you after the project has been created? (recommended) npm
74
+
75
+ ```
76
+
77
+ 2.componentsにTest.vueを作成
78
+
79
+ ```Vue
80
+
81
+ <template>
82
+
83
+ <div>
84
+
85
+ <button @click="test">login</button>
86
+
87
+ </div>
88
+
89
+ </template>
90
+
91
+ <script>
92
+
93
+ export default {
94
+
95
+ methods: {
96
+
97
+ test: function () {
98
+
99
+ console.log('Hello world')
100
+
101
+ }
102
+
103
+ }
104
+
105
+ }
106
+
107
+ </script>
108
+
109
+ <style>
110
+
111
+ </style>
112
+
113
+ ```
114
+
115
+ 3.index.jsに一部追加
116
+
117
+ ```js
118
+
119
+ import Vue from 'vue'
120
+
121
+ import Router from 'vue-router'
122
+
123
+ import HelloWorld from '@/components/HelloWorld'
124
+
125
+ import Test from '@/components/Test' // 追加部分
126
+
127
+
128
+
129
+ Vue.use(Router)
130
+
131
+
132
+
133
+ export default new Router({
134
+
135
+ routes: [
136
+
137
+ {
138
+
139
+ path: '/',
140
+
141
+ name: 'HelloWorld',
142
+
143
+ component: HelloWorld
144
+
145
+ },
146
+
147
+ // 追加部分
148
+
149
+ {
150
+
151
+ path: '/test',
152
+
153
+ name: 'test',
154
+
155
+ component: Test
156
+
157
+ }
158
+
159
+ ]
160
+
161
+ })
162
+
163
+ ```

2

質問文の修正

2018/12/07 11:58

投稿

Matt
Matt

スコア41

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,6 @@
1
1
  Vue routerを使って簡単なSPAを作っています。
2
2
 
3
- App.vueのrouter-viewタグ内にTest.vueを読み込んで、clickイベントを発火させたいのですが、くいきません。
3
+ App.vueのrouter-viewタグ内にTest.vueを読み込んで、clickイベントの動作確認行いたいのですが、コンソール出力がありません。
4
4
 
5
5
 
6
6
 

1

必要ない部分をカット

2018/12/07 09:52

投稿

Matt
Matt

スコア41

test CHANGED
File without changes
test CHANGED
@@ -40,96 +40,6 @@
40
40
 
41
41
  <style>
42
42
 
43
- .login-page {
44
-
45
- width: 360px;
46
-
47
- padding: 8% 0 0;
48
-
49
- margin: auto;
50
-
51
- }
52
-
53
- .form {
54
-
55
- position: relative;
56
-
57
- z-index: 1;
58
-
59
- background: #FFFFFF;
60
-
61
- max-width: 360px;
62
-
63
- margin: 0 auto 100px;
64
-
65
- padding: 45px;
66
-
67
- text-align: center;
68
-
69
- box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
70
-
71
- }
72
-
73
- .form input {
74
-
75
- font-family: "Roboto", sans-serif;
76
-
77
- outline: 0;
78
-
79
- background: #f2f2f2;
80
-
81
- width: 100%;
82
-
83
- border: 0;
84
-
85
- margin: 0 0 15px;
86
-
87
- padding: 15px;
88
-
89
- box-sizing: border-box;
90
-
91
- font-size: 14px;
92
-
93
- }
94
-
95
- .form button {
96
-
97
- font-family: "Roboto", sans-serif;
98
-
99
- text-transform: uppercase;
100
-
101
- outline: 0;
102
-
103
- background: #4CAF50;
104
-
105
- width: 100%;
106
-
107
- border: 0;
108
-
109
- padding: 15px;
110
-
111
- color: #FFFFFF;
112
-
113
- font-size: 14px;
114
-
115
- -webkit-transition: all 0.3 ease;
116
-
117
- transition: all 0.3 ease;
118
-
119
- cursor: pointer;
120
-
121
- }
122
-
123
- .form button:hover,.form button:active,.form button:focus {
124
-
125
- background: #43A047;
126
-
127
- }
128
-
129
43
  </style>
130
44
 
131
-
132
-
133
-
134
-
135
45
  ```