index.js 588 字节
Newer Older
DCloud_JSON's avatar
DCloud_JSON 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
import init from './init/index.js';
import methods from './methods/index.js';
import state from './state/index.js';
import utils from './utils/index.js';

export default utils.deepAssign(state,methods,{init,utils}, {
  mapState(keys = []) {
    let obj = {}
    keys.forEach((key) => {
      let keyName = key,
        keyCName = false
      if (key.includes(' as ')) {
        let _key = key.trim().split(' as ')
        keyName = _key[0]
        keyCName = _key[1]
      }
      obj[keyCName || keyName] = function () {
        return state[keyName]
      }
    })
    return obj
  }
})