扫码关注官方订阅号
// mutation-types.js export const SOME_MUTATION = 'SOME_MUTATION' export const SOME_MUTATION_1 = 'SOME_MUTATION_1'
我要import引入mutation-types.js,怎么写比较好?
小伙看你根骨奇佳,潜力无限,来学PHP伐。
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)
如果你想全部导入: import * as mutationTypes from './mutation-types'; 如果你只是想导入 mutation-types里的几个可以: import {SOME_MUTATION,SOME_MUTATION_1} from './mutation-types';
你可以吧SOME_MUTATION和SOME_MUTATION_1放在一个export的对象里面呀:
let obj = { SOME_MUTATION : 'SOME_MUTATION', SOME_MUTATION_1 : 'SOME_MUTATION_1' } export obj
http://es6.ruanyifeng.com/#do...
引入import * as types from '../../mutation-types';使用types.SOME_MUTATIONtypes.SOME_MUTATION_1
import * as types from './types';
然后用 types[导出名] 可以使用
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
你可以吧SOME_MUTATION和SOME_MUTATION_1放在一个export的对象里面呀:
http://es6.ruanyifeng.com/#do...
引入
import * as types from '../../mutation-types';
使用
types.SOME_MUTATION
types.SOME_MUTATION_1
然后用 types[导出名] 可以使用