lzxb / vuet

允许你定义飙车过程的集中式状态管理模式

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

在fetch中不能写异步请求?

laodifanga opened this issue · comments

import {addressList} from '@/api'
import { mapModules, mapRules } from 'vuet'

const mixins = [
  mapModules({
    $address: 'address'
  }),
  mapRules({
    once: [{ path: 'address' }]
  })
]

export default {
  mixins,
  module: {
    data () {
      return {
        data: ''
      }
    },
    fetch (uid) {
      setTimeout(() => {
         this.data = 'fetch'
      }, 1000)
      

    },
    async getData(uid = 1) {
      setTimeout(() => {
        this.data = 111
      }, 1000)

      return
      let res = await addressList({uid})
      this.data = res.data
    }
  }
}

这么写 data 返回的 居然是 function proxy() { return native.apply(vuet.modules[path], arguments); }

commented

addressList 是什么?