map.js
1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const map = () => {
const store = Vuex.useStore()
/**
* 获取count,
* 用computed实现相应
*/
const getCount = () => {
return Vue.computed(() => store.state.count)
}
/**
* 获取count,
** 用 ref 实现相应
*/
const getRefCount = () => {
return Vue.ref(store.state.count)
}
/**
* 获取对象
*/
const getObject = () => {
return store.state.myObject
}
/**
* 获取只读对象
*/
const getReadonlyObject = () => {
return Vue.readonly(store.state.myObject)
}
/**
* 获取数组
*/
const getArray = () => {
return store.state.myArray
}
/**
* 获取只读数组
*/
const getReadonlyArray = () => {
return Vue.readonly(store.state.myArray)
}
/**
* 查询数组
** id:要查询的数据
*/
const filterArray = (id) => {
return Vue.computed(() => store.getters.filterArray(id))
}
return {
getCount,
getRefCount,
getObject,
getReadonlyObject,
getArray,
getReadonlyArray,
filterArray
}
}
export default map