Skip to content

Commit 9b99a5a

Browse files
committed
chore: add docs
1 parent 6039d64 commit 9b99a5a

File tree

1 file changed

+133
-1
lines changed

1 file changed

+133
-1
lines changed

README.md

Lines changed: 133 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,134 @@
11
# vue-function-api-extra
2-
Providing plugin and helper functions for vue-function-api, so that we can use vue-route, vuex, mixins, prototype helpers ...
2+
3+
Providing plugin and helper functions for [vue-function-api](https://github.com/vuejs/vue-function-api), so that we can use vue-route, vuex, helpers in prototype ...
4+
5+
```js
6+
7+
import { useGetters } from 'vue-function-api-extra'
8+
import {
9+
value,
10+
} from 'vue-function-api'
11+
12+
export default {
13+
setup(props, context){
14+
15+
const getters = useGetters(context, ['userInfo', 'otherGetter'])
16+
17+
// use route
18+
const route = context.route
19+
const id = value(route.params.id)
20+
const goBack = () => {
21+
context.router.goBack()
22+
}
23+
24+
// use store
25+
const store = context.store
26+
27+
// use properties
28+
// if you run "Vue.prototype.$isAndroid = true" before
29+
const isAndroid = context.isAndroid
30+
31+
32+
return {
33+
...getters,
34+
id,
35+
goBack,
36+
}
37+
}
38+
39+
}
40+
41+
```
42+
43+
# install
44+
45+
```
46+
yarn add vue-function-api-extra
47+
```
48+
49+
or
50+
51+
```
52+
npm install vue-function-api-extra --save
53+
```
54+
55+
# Install Plugin
56+
57+
First you should install the plugins.
58+
59+
**Notice: You should install the plugin before other plugins installed**
60+
61+
```js
62+
63+
import Vue from 'vue'
64+
import { plugin } from 'vue-function-api-extra'
65+
66+
Vue.use(plugin)
67+
68+
// use other plugins
69+
70+
```
71+
72+
# Use properties in context
73+
74+
```js
75+
export default {
76+
setup(props, context){
77+
78+
// use route
79+
const route = context.route
80+
81+
// use store
82+
const store = context.store
83+
84+
// use properties
85+
// if you run "Vue.prototype.$isAndroid = true" before
86+
const isAndroid = context.isAndroid
87+
88+
return {
89+
...getters
90+
}
91+
}
92+
93+
}
94+
```
95+
96+
97+
# Helpers
98+
99+
## useGetters
100+
101+
### description
102+
103+
use Getters in Vuex
104+
105+
### params
106+
107+
#### context
108+
109+
**description:** Setup Context in ```vue-function-api```
110+
**type:** SetupContext
111+
112+
113+
#### getters
114+
115+
**description** names of getters
116+
**type:** string[]
117+
118+
### example
119+
120+
```js
121+
import { useGetters } from 'vue-function-api-extra'
122+
123+
export default {
124+
setup(props, context){
125+
126+
const getters = useGetters(context, ['userInfo', 'otherGetter'])
127+
128+
return {
129+
...getters
130+
}
131+
}
132+
133+
}
134+
```

0 commit comments

Comments
 (0)