javascript - How to introduce multiple exports when there are multiple exports in js?
伊谢尔伦
伊谢尔伦 2017-05-19 10:11:30
0
7
744
// mutation-types.js
export const SOME_MUTATION = 'SOME_MUTATION'
export const SOME_MUTATION_1 = 'SOME_MUTATION_1'

I want to import mutation-types.js, how to write it better?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(7)
大家讲道理
import * as types from 'mutation-types.js'
// types.SOME_MUTATION types.SOME_MUTATION_1
習慣沉默
import * as TYPES from './mutation-types';

console.log(TYPES.SOME_MUTATION)
PHPzhong
如果你想全部导入:
import * as mutationTypes from './mutation-types';
如果你只是想导入 mutation-types里的几个可以:

import {SOME_MUTATION,SOME_MUTATION_1} from './mutation-types';
左手右手慢动作

You can put SOME_MUTATION and SOME_MUTATION_1 in an export object:

let obj = {
    SOME_MUTATION : 'SOME_MUTATION',
    SOME_MUTATION_1 : 'SOME_MUTATION_1'
}

export obj
左手右手慢动作

http://es6.ruanyifeng.com/#do...

给我你的怀抱

Introduce
import * as types from '../../mutation-types';
Use
types.SOME_MUTATION
types.SOME_MUTATION_1

漂亮男人
import * as types from './types';

Then use types[export name] to use

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template