https://github.com/chrisbing/vue-function-api-extra
Providing plugin and helper functions for vue-function-api, so that we can use vue-route, vuex, mixins, prototype helpers ...
https://github.com/chrisbing/vue-function-api-extra
vue vue-function-api
Last synced: 11 months ago
JSON representation
Providing plugin and helper functions for vue-function-api, so that we can use vue-route, vuex, mixins, prototype helpers ...
- Host: GitHub
- URL: https://github.com/chrisbing/vue-function-api-extra
- Owner: chrisbing
- License: mit
- Created: 2019-08-19T11:31:29.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-08-11T09:16:29.000Z (over 4 years ago)
- Last Synced: 2025-03-18T16:04:06.948Z (11 months ago)
- Topics: vue, vue-function-api
- Language: TypeScript
- Size: 23.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vue-function-api-extra
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 ...
```js
import { useGetters } from 'vue-function-api-extra'
import {
value,
} from 'vue-function-api'
export default {
setup(props, context){
const getters = useGetters(context, ['userInfo', 'otherGetter'])
// use route
const route = context.route
const id = value(route.params.id)
const goBack = () => {
context.router.goBack()
}
// use store
const store = context.store
// use properties
// if you run "Vue.prototype.$isAndroid = true" before
const isAndroid = context.isAndroid
return {
...getters,
id,
goBack,
}
}
}
```
# install
```
yarn add vue-function-api-extra
```
or
```
npm install vue-function-api-extra --save
```
# Install Plugin
First you should install the plugins.
**Notice: You should install the plugin before other plugins installed**
```js
import Vue from 'vue'
import { plugin } from 'vue-function-api-extra'
Vue.use(plugin)
// use other plugins
```
# Use properties in context
```js
export default {
setup(props, context){
// use route
const route = context.route
// use store
const store = context.store
// use properties
// if you run "Vue.prototype.$isAndroid = true" before
const isAndroid = context.isAndroid
return {
...getters
}
}
}
```
# Helpers
## useGetters
### description
use Getters in Vuex
### params
#### context
**description:** Setup Context in ```vue-function-api```
**type:** SetupContext
#### getters
**description** names of getters
**type:** string[]
### example
```js
import { useGetters } from 'vue-function-api-extra'
export default {
setup(props, context){
const getters = useGetters(context, ['userInfo', 'otherGetter'])
return {
...getters
}
}
}
```