@ddot/umi-plugin-vue
v0.0.7
Published
A umi plugin for support vuejs
Downloads
2
Maintainers
Readme
umi-plugin-vue
umi
服务接口插件。
配置
.umirc.js
@ddot/umi-plugin-vue
插件默认配置
export default {
plugins: [
[
'@ddot/umi-plugin-vue',
{
dva: {
immer: true,
},
routes: {
exclude: [/model/],
},
dll: {
include: []
},
dynamicImport: {
webpackChunkName: true
}
}
]
]
};
扩展API
当使用本插件后,umi
项目中会新增一个API: @ddot/umi-vue
<template>
<div>
Hello, {{ isAuth }} {{ name }}! <br />
<button @click="onClick">touch me</button>
</div>
</template>
<script>
import { mapState, dispatch } from '@ddot/umi-vue'
export default {
computed: {
...mapState({
isAuth: state => state.model.isAuth,
}),
...mapState('model',[
'name'
])
},
methods: {
onClick() {
dispatch({type:'model/logout'})
},
},
};
</script>
export default {
namespace: 'model',
state: {
isAuth: false,
name: 'ddot',
},
reducers: {
changeAuth(state) {
state.isAuth = true;
},
},
effects: {
*logout(_, { call, put }) {
yield put({
type: 'changeAuth',
});
},
},
};