How do i write this require as an es6 import statement

前端 未结 3 1979
逝去的感伤
逝去的感伤 2020-12-20 01:56

Problem

I have this require statement

require(\'smoothscroll-polyfill\').polyfill();

But I would like to write it as an es6 impor

3条回答
  •  不知归路
    2020-12-20 02:31

    Assuming you're using Babel or something similar to provide compatibility between CommonJS modules and ES6 modules, the syntax would look something like this:

    import smoothscrollPolyfill from "smoothscroll-polyfill";
    smoothscrollPolyfill.polyfill();
    

提交回复
热议问题