有的时候,可以输出'aaa'
但有的时候,会// Uncaught ReferenceError: require is not defined
图片描述
<code>require.config({
baseUrl: '<?php echo $this->config->base_url(); ?>',
paths: {
jquery: 'assets/js/jquery.min',
bootstrap: 'assets/js/bootstrap.min',
fastclick: 'assets/js/fastclick',
swal: 'assets/js/sweet-alert',
bootstrapSelect: 'assets/js/bootstrap-select.min',
ueditorConfig: 'assets/js/ueditor/ueditor.config',
ueditor: 'assets/js/ueditor/ueditor.all.min',
domReady: 'assets/js/domReady'
},
shim: {
bootstrap: {
deps: ['jquery'],
exports: 'bootstrap'
}
},
urlArgs: 'v=' + (new Date()).getTime()
});
require(['domReady'],function(domReady){
domReady(function(){
console.log('aaa');
});
});
// Uncaught ReferenceError: require is not defined
</code>有的时候,可以输出'aaa'
但有的时候,会// Uncaught ReferenceError: require is not defined
图片描述
<code>require.config({
baseUrl: '<?php echo $this->config->base_url(); ?>',
paths: {
jquery: 'assets/js/jquery.min',
bootstrap: 'assets/js/bootstrap.min',
fastclick: 'assets/js/fastclick',
swal: 'assets/js/sweet-alert',
bootstrapSelect: 'assets/js/bootstrap-select.min',
ueditorConfig: 'assets/js/ueditor/ueditor.config',
ueditor: 'assets/js/ueditor/ueditor.all.min',
domReady: 'assets/js/domReady'
},
shim: {
bootstrap: {
deps: ['jquery'],
exports: 'bootstrap'
}
},
urlArgs: 'v=' + (new Date()).getTime()
});
require(['domReady'],function(domReady){
domReady(function(){
console.log('aaa');
});
});
// Uncaught ReferenceError: require is not defined
</code>
其实一般大家在生产环境里的时候是不会引用requirejs,上线的都是打包好的。
引入requirejs去掉asyn和defer属性
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号