Comments (4)
Hi, you can refer to this example:
<script>
import { createComponent } from 'vue-function-api';
import { useState, useGetters, useMutations, useActions } from '@u3u/vue-hooks';
export default createComponent({
name: 'App',
setup() {
const state = {
...useState(['count']),
};
const getters = {
...useGetters(['plusOne']),
};
const mutations = {
...useMutations(['increment', 'decrement']),
};
const actions = {
...useActions(['incrementAsync', 'decrementAsync']),
};
return {
...state,
...getters,
state,
getters,
mutations,
actions,
};
},
render() {
const { count, plusOne, state, getters, mutations, actions } = this;
console.log(count); // number
console.log(plusOne); // number
console.log(state.count); // ComputedWrapper
console.log(getters.plusOne); // ComputedWrapper
return (
<div id="app">
<div>count(state): {count}</div>
<div>plusOne(getters): {plusOne}</div>
<button onClick={() => mutations.increment()}>increment</button>
<button onClick={() => mutations.decrement()}>decrement</button>
<button onClick={() => actions.incrementAsync()}>incrementAsync</button>
<button onClick={() => actions.decrementAsync()}>decrementAsync</button>
</div>
);
},
});
</script>
from vue-hooks.
Regard @u3u ,
I recommend if you can, add that type of structure (example) as documentation for official use.
from vue-hooks.
Yes, I am writing documentation and examples.
I usually work very busy, only available on weekends. 😅
from vue-hooks.
Welcome to visit: https://vue-hooks.netlify.com
from vue-hooks.
Related Issues (20)
- Dependabot can't resolve your JavaScript dependency files HOT 1
- use @storybook/addon-storysource plugin to show the demo source HOT 1
- submit a pull request to https://github.com/vuejs/composition-api HOT 2
- Dependabot can't resolve your JavaScript dependency files HOT 1
- Dependabot can't resolve your JavaScript dependency files HOT 1
- Dependabot can't resolve your JavaScript dependency files HOT 1
- Dependabot can't resolve your JavaScript dependency files HOT 1
- Dependabot can't resolve your JavaScript dependency files HOT 1
- Dependabot can't resolve your JavaScript dependency files HOT 1
- Dependabot can't resolve your JavaScript dependency files HOT 1
- Dependabot can't resolve your JavaScript dependency files HOT 1
- Dependabot can't resolve your JavaScript dependency files HOT 1
- Add generic support to vuex hooks HOT 1
- Dependabot can't resolve your JavaScript dependency files HOT 1
- How can we mount components with vue-hooks in unit test HOT 8
- Getter does not accept payload HOT 3
- Could I create custom `useCustom()`? HOT 1
- build fail due to duplication with dayjs HOT 2
- features request: when to get Vuex instance
- support for vue 2.7 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-hooks.