Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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