翻译require()语法以导入语法节点js

时间:2017-09-26 12:47:13

标签: javascript node.js typescript syntax

我在应用程序中使用strong-soap包。在将require()转换为import语句时,我面临以下语法问题。

var soap = require('strong-soap').soap;
     to 
import soap from 'strong-soap.soap' // doesn't work also throwing syntax error
import soap from 'strong-soap';//not working as expected

感谢您的帮助

1 个答案:

答案 0 :(得分:6)

soap是strong-soap的对象,因此以下内容可行 - ES6模块导入。

import { soap } from 'strong-soap';