我来自一个角度的心态,现在我想学习vue.js.我正在使用webpack,并且我有以下三个.vue
类。 CounterDisplay.vue
,IncrementButton.vue , and
App.vue . I want to increment the
count 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
module 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