質問編集履歴
3
詳細を追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -20,4 +20,63 @@
|
|
20
20
|
</script>
|
21
21
|
<style>
|
22
22
|
</style>
|
23
|
+
```
|
24
|
+
|
25
|
+
# 追記:試したことの詳細
|
26
|
+
1.プロジェクトを作成
|
27
|
+
```
|
28
|
+
$ vue init webpack test
|
29
|
+
? Project name test
|
30
|
+
? Project description A Vue.js project
|
31
|
+
? Author
|
32
|
+
? Vue build standalone
|
33
|
+
? Install vue-router? Yes
|
34
|
+
? Use ESLint to lint your code? No
|
35
|
+
? Set up unit tests No
|
36
|
+
? Setup e2e tests with Nightwatch? No
|
37
|
+
? Should we run `npm install` for you after the project has been created? (recommended) npm
|
38
|
+
```
|
39
|
+
2.componentsにTest.vueを作成
|
40
|
+
```Vue
|
41
|
+
<template>
|
42
|
+
<div>
|
43
|
+
<button @click="test">login</button>
|
44
|
+
</div>
|
45
|
+
</template>
|
46
|
+
<script>
|
47
|
+
export default {
|
48
|
+
methods: {
|
49
|
+
test: function () {
|
50
|
+
console.log('Hello world')
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
</script>
|
55
|
+
<style>
|
56
|
+
</style>
|
57
|
+
```
|
58
|
+
3.index.jsに一部追加
|
59
|
+
```js
|
60
|
+
import Vue from 'vue'
|
61
|
+
import Router from 'vue-router'
|
62
|
+
import HelloWorld from '@/components/HelloWorld'
|
63
|
+
import Test from '@/components/Test' // 追加部分
|
64
|
+
|
65
|
+
Vue.use(Router)
|
66
|
+
|
67
|
+
export default new Router({
|
68
|
+
routes: [
|
69
|
+
{
|
70
|
+
path: '/',
|
71
|
+
name: 'HelloWorld',
|
72
|
+
component: HelloWorld
|
73
|
+
},
|
74
|
+
// 追加部分
|
75
|
+
{
|
76
|
+
path: '/test',
|
77
|
+
name: 'test',
|
78
|
+
component: Test
|
79
|
+
}
|
80
|
+
]
|
81
|
+
})
|
23
82
|
```
|
2
質問文の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
Vue routerを使って簡単なSPAを作っています。
|
2
|
-
App.vueのrouter-viewタグ内にTest.vueを読み込んで、clickイベントを
|
2
|
+
App.vueのrouter-viewタグ内にTest.vueを読み込んで、clickイベントの動作確認を行いたいのですが、コンソール出力がありません。
|
3
3
|
|
4
4
|
App.vueに、Test.vueのtemplateは読み込むことができています。
|
5
5
|
以下はTest.vueです。どうすれば、クリックイベントを取得できるでしょうか。
|
1
必要ない部分をカット
title
CHANGED
File without changes
|
body
CHANGED
@@ -19,50 +19,5 @@
|
|
19
19
|
}
|
20
20
|
</script>
|
21
21
|
<style>
|
22
|
-
.login-page {
|
23
|
-
width: 360px;
|
24
|
-
padding: 8% 0 0;
|
25
|
-
margin: auto;
|
26
|
-
}
|
27
|
-
.form {
|
28
|
-
position: relative;
|
29
|
-
z-index: 1;
|
30
|
-
background: #FFFFFF;
|
31
|
-
max-width: 360px;
|
32
|
-
margin: 0 auto 100px;
|
33
|
-
padding: 45px;
|
34
|
-
text-align: center;
|
35
|
-
box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
|
36
|
-
}
|
37
|
-
.form input {
|
38
|
-
font-family: "Roboto", sans-serif;
|
39
|
-
outline: 0;
|
40
|
-
background: #f2f2f2;
|
41
|
-
width: 100%;
|
42
|
-
border: 0;
|
43
|
-
margin: 0 0 15px;
|
44
|
-
padding: 15px;
|
45
|
-
box-sizing: border-box;
|
46
|
-
font-size: 14px;
|
47
|
-
}
|
48
|
-
.form button {
|
49
|
-
font-family: "Roboto", sans-serif;
|
50
|
-
text-transform: uppercase;
|
51
|
-
outline: 0;
|
52
|
-
background: #4CAF50;
|
53
|
-
width: 100%;
|
54
|
-
border: 0;
|
55
|
-
padding: 15px;
|
56
|
-
color: #FFFFFF;
|
57
|
-
font-size: 14px;
|
58
|
-
-webkit-transition: all 0.3 ease;
|
59
|
-
transition: all 0.3 ease;
|
60
|
-
cursor: pointer;
|
61
|
-
}
|
62
|
-
.form button:hover,.form button:active,.form button:focus {
|
63
|
-
background: #43A047;
|
64
|
-
}
|
65
22
|
</style>
|
66
|
-
|
67
|
-
|
68
23
|
```
|