lzxb / vuet

允许你定义飙车过程的集中式状态管理模式
MIT License
422 stars 74 forks source link

在fetch中不能写异步请求? #18

Closed laodifanga closed 6 years ago

laodifanga commented 6 years ago
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); }

lzxb commented 6 years ago

addressList 是什么?