first commit
This commit is contained in:
26
testmulticomponent/components/ComponentA.js
Normal file
26
testmulticomponent/components/ComponentA.js
Normal file
@@ -0,0 +1,26 @@
|
||||
// components/ComponentA.js
|
||||
|
||||
const ComponentA = {
|
||||
template: `
|
||||
<div>
|
||||
<h2>Component A</h2>
|
||||
<p>Count: {{ count }}</p>
|
||||
<v-btn @click="increment">Increment</v-btn>
|
||||
<v-btn @click="decrement">Decrement</v-btn>
|
||||
</div>
|
||||
`,
|
||||
computed: {
|
||||
count() {
|
||||
return this.$store.state.count;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
increment() {
|
||||
this.$store.dispatch('increment');
|
||||
},
|
||||
decrement() {
|
||||
this.$store.dispatch('decrement');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
22
testmulticomponent/components/ComponentB.js
Normal file
22
testmulticomponent/components/ComponentB.js
Normal file
@@ -0,0 +1,22 @@
|
||||
// components/ComponentB.js
|
||||
|
||||
const ComponentB = {
|
||||
template: `
|
||||
<div>
|
||||
<h2>Component B</h2>
|
||||
<p>Data: {{ data }}</p>
|
||||
<v-btn @click="fetchData">Fetch Data</v-btn>
|
||||
</div>
|
||||
`,
|
||||
computed: {
|
||||
data() {
|
||||
return this.$store.state.data;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async fetchData() {
|
||||
await this.$store.dispatch('fetchData');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user