首页 > 解决方案 > 翻译成es6导入

问题描述

如何翻译成es6导入?

const bodyParser = require('body-parser');
require('body-parser-xml')(bodyParser);

我只知道50%

import * as bodyParser from 'body-parser';

但是如何添加最后的 50%?

标签: reactjsecmascript-6import

解决方案


第二部分导入并调用一个函数,传递bodyParser. 尝试

import * as bodyParserXml from 'body-parser-xml';

bodyParserXml(bodyParser);

推荐阅读