init commit
This commit is contained in:
28
src/stores/Point.js
Normal file
28
src/stores/Point.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
|
||||
export const usePointStore = defineStore({
|
||||
id: 'point',
|
||||
state: () => ({
|
||||
index: 0,
|
||||
length: 10,
|
||||
rawItems: [],
|
||||
}),
|
||||
getters: {
|
||||
items: (state) => {
|
||||
const items = state.rawItems
|
||||
items.length = state.length
|
||||
|
||||
return items
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
addItem(item) {
|
||||
if (this.index >= this.length) {
|
||||
return
|
||||
}
|
||||
this.rawItems[this.index] = item
|
||||
this.index++
|
||||
},
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user