나는 각성적인 생각에서 왔으며 지금은 vue.js를 배우려고합니다. 나는 webpack을 사용하고 있으며 다음 세 개의 .vue
클래스가 있습니다. CounterDisplay.vue
, IncrementButton.vue , and
App.vue . I want to increment the
카운트 variable but all it does is
console.log how many times I pressed the button. I am trying to figure out how child to parent and parent to child work in vue. Then I need to figure out the correct pattern to use vue in a very large application. In angular you have a
모듈 and in there you put your components and services etc. How does
vue` do this?구성 요소와 이야기하기 부모와 자녀의 부모 vue.js
CounterDisplay.vue
<template>
<div id="#counterDisplay">
{{count}}
</div>
</template>
<script>
export default {
data() {
return {
count: 0
}
}
}
</script>
<style scoped>
</style>
IncrementButton.vue
<template>
<button @click.prevent="active">+1</button>
</template>
<script>
export default {
methods: {
active() {
console.log('+1 Pressed')
}
}
}
</script>
<style scoped></style>
App.vue
<template>
<div id="app">
<h3>Increment:</h3>
<increment></increment>
<h3>Counter:</h3>
<counter></counter>
</div>
</template>
<script>
import Counter from './components/CounterDisplay.vue'
import Increment from './components/IncrementButton.vue'
export default {
components: {
Counter,
Increment
}
}
</script>
<style>
</style>
을 사용하는 것이 좋습니다. 무엇이 문제인가요? – samayo
@samayo 죄송합니다. 내 질문을 업데이트했습니다. 나는 한 번 더 질문을 더했는데, 나는 하나 이상의 질문을해서는 안된다는 것을 알았지 만 그것은 내 질문에 어느 정도 관련되어있다. – Drew1208