We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
webpack打包工具现在是超级流行,插件超多;成为目前最主流的打包工具。模块间的引入都是采用require的方式(ES6 用 import)来引入自身的依赖。
一般大家用require的时候都是采用以下几种方式;
require('./a.js')
require('./a')
var a=require('a') var b=require('b') ..... var n=require('n') eval(opt)():
有一个非常明显的缺点,需要显式的require所有模块;
var o={ a:'./a' b:'./a' ... n:'./a' } require(s[opt])
采用参数配置的方式,动态的根据opt的值来决定加载相应的模块。
The text was updated successfully, but these errors were encountered:
突然发现webpack 也支持 require('./view/'+id+'.html') 这种方式了
Sorry, something went wrong.
No branches or pull requests
一般大家用require的时候都是采用以下几种方式;
载入当前目录下的a.js
方法1:
方法2
如果当前目录下有a,b,c,d....N个模块,当前模块有一个参数配置opt,这个配置是调用该模块的主模块传入的,决定引入那个子模块(a,b,c,d...),那么这个require应该怎么来写?
第一种写法
有一个非常明显的缺点,需要显式的require所有模块;
第二中写法
采用参数配置的方式,动态的根据opt的值来决定加载相应的模块。
The text was updated successfully, but these errors were encountered: