package list from viandwi24
This commit is contained in:
25
stores/counter.ts
Normal file
25
stores/counter.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export interface ICounterState {
|
||||
count: number
|
||||
}
|
||||
|
||||
export const useCounter = defineStore('counter', {
|
||||
state: (): ICounterState => ({
|
||||
count: 0,
|
||||
}),
|
||||
actions: {
|
||||
increment() {
|
||||
this.count++
|
||||
},
|
||||
decrement() {
|
||||
this.count--
|
||||
},
|
||||
reset() {
|
||||
this.count = 0
|
||||
},
|
||||
increment2x() {
|
||||
this.count *= 2
|
||||
},
|
||||
},
|
||||
})
|
||||
30
stores/identity.ts
Normal file
30
stores/identity.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export interface IIdentityState {
|
||||
firstName: string
|
||||
lastName: string
|
||||
}
|
||||
|
||||
export const useIdentity = defineStore('identity', {
|
||||
state: (): IIdentityState => ({
|
||||
firstName: 'Alfian',
|
||||
lastName: 'Dwi',
|
||||
}),
|
||||
actions: {
|
||||
setFirstName(firstName: string) {
|
||||
this.firstName = firstName
|
||||
},
|
||||
setLastName(lastName: string) {
|
||||
this.lastName = lastName
|
||||
},
|
||||
reset() {
|
||||
this.firstName = 'Alfian'
|
||||
this.lastName = 'Dwi'
|
||||
},
|
||||
},
|
||||
getters: {
|
||||
fullName(): string {
|
||||
return `${this.firstName} ${this.lastName}`
|
||||
},
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user