ES6 imports - what does the exclamation mark mean?

£可爱£侵袭症+ 提交于 2019-12-21 03:53:12

问题


I'm following along with the Choose ES6 Modules Today guide, and I noticed one of the import statements he's using has an exclamation mark at the end:

import 'bootstrap/css/bootstrap.css!';

What does that exclamation mark signify?

This import statement appears on the first line of the startup.js file.


回答1:


It means that a plugin will be called to load the file. By default the plugin/loader name equals the extension name. So in your example the css plugin will be called to load the bootstrap/css/bootstrap.css file. One can define the plugin explicitly:

import 'bootstrap/css/bootstrap.css!css';

or

import 'bootstrap/css/bootstrap.css!customCssLoader';

Plugins have to be installed like any other normal module. More about this syntax here.



来源:https://stackoverflow.com/questions/31620018/es6-imports-what-does-the-exclamation-mark-mean

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!