@ddot/umi-plugin-vue

0.0.7 • Public • Published

umi-plugin-vue

NPM version code style: prettier MIT

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',
      });
    },
  },
};

Package Sidebar

Install

npm i @ddot/umi-plugin-vue

Weekly Downloads

0

Version

0.0.7

License

MIT

Unpacked Size

25 kB

Total Files

16

Last publish

Collaborators

  • ddotjs