Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/martian-in-earth/dva-vue
🌱 Vue and dva-core based
https://github.com/martian-in-earth/dva-vue
dva redux redux-saga vue vue-router
Last synced: 7 days ago
JSON representation
🌱 Vue and dva-core based
- Host: GitHub
- URL: https://github.com/martian-in-earth/dva-vue
- Owner: Martian-in-Earth
- License: mit
- Created: 2017-09-12T08:04:32.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-09-19T07:58:13.000Z (about 6 years ago)
- Last Synced: 2024-10-27T15:48:09.718Z (11 days ago)
- Topics: dva, redux, redux-saga, vue, vue-router
- Language: JavaScript
- Homepage:
- Size: 276 KB
- Stars: 34
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dva-vue
[![NPM version](https://img.shields.io/npm/v/dva-vue.svg?style=flat)](https://npmjs.org/package/dva-vue)
[![Build Status](https://img.shields.io/travis/jetsly/dva-vue.svg?style=flat)](https://travis-ci.org/jetsly/dva-vue)
[![Coverage Status](https://img.shields.io/coveralls/jetsly/dva-vue.svg?style=flat)](https://coveralls.io/r/jetsly/dva-vue)
[![NPM downloads](http://img.shields.io/npm/dm/dva-vue.svg?style=flat)](https://npmjs.org/package/dva-vue)
[![Dependencies](https://david-dm.org/jetsly/dva-vue/status.svg)](https://david-dm.org/jetsly/dva-vue)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com)
[![MIT](https://img.shields.io/dub/l/vibe-d.svg?style=flat-square)](http://opensource.org/licenses/MIT)[![NPM](https://nodei.co/npm/dva-vue.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/dva-vue/)
> Lightweight front-end framework based on [dva-core](https://github.com/dvajs/dva/tree/master/packages/dva-core) and [history](https://github.com/ReactTraining/history)
> What's [dva.js](https://dvajs.com/)?## Demos & Plugins
- [dva-nprogress](https://github.com/Jetsly/dva-vue/tree/master/packages/dva-nprogress): dva-vue plugin
- [dva-vue-example](https://github.com/Jetsly/dva-vue/tree/master/packages/dva-vue-example): dva-vue demos---
### Install
```bash
$ npm install --save dva-vue
```### Usage Example
```App.vue
count: {{count}}
import {connect} from 'dva-vue'
export default connect(({count}) => ({count}))({
methods: {
add () {
this.dispatch({type: 'count/add'})
},
asyncAdd () {
this.dispatch({type: 'count/asyncAdd'}).then(()=>console.log('done'))
}
}
})```
```javascript
import dva, { createHashHistory } from 'dva-vue'
import App from 'App.vue'const delay = ms => new Promise((resolve, reject) => setTimeout(() => resolve(), ms))
const app = dva({
history: createHashHistory() // 默认值
})
app.model({
namespace: 'count',
state: 0,
reducers: {
add (state, { payload }) { return state + payload || 1 },
minus (state, { payload }) { return state - payload || 1 }
},
effects: {
* asyncAdd(_, {call, put}){
// as some fetch action
yield delay(1000)
yield put({type: 'add', payload: 1})
}
}
})
app.router(() => [{ path: '/', component: App }])
app.start('#root')
```## API Reference
```javascript
import dva, {
connect,
dynamic
} from 'dva-vue'
```## LICENSE
MIT