Currencies.js
Verbose
Test.js
Install-Package FSharp.Core -Version X
index.js
var Currency = {};
Currency["USA"] = "dollar";
Currency["INDIA"] = "rupee";
Currency["CHINA"] = "yuan";
export { Currency };
问题出在import { Currency } from './currencies';
export { Currency.USA as USA }; // wrong
export { Currency.CHINA as CHINA }; // wrong
export { Currency.INDIA as INDIA }; // wrong
。我用于命名导出的语法是错误的。有人可以纠正吗?如何从其他位置导入对象时单独导出对象值。
答案 0 :(得分:2)
嗯,这太琐碎了
#1方法:
const Currency = {
USA: 'dollar',
INDIA: 'rupee',
CHINA: 'yuan'
}
export const { USA, INDIA, CHINA } = Currency;
#2方法(与#1相同)
export const { USA, INDIA, CHINA } = {
USA: 'dollar',
INDIA: 'rupee',
CHINA: 'yuan'
};
#3方法:
export const USA = 'dollar';
export const INDIA = 'rupee';
export const CHINA = 'yuan';
您可以像使用(所有方法)一样使用它:
import {USA} form './Currencies'