RequireJS 加载 js 执行顺序
2016-04-26 14:51
411 查看
初次接触RequireJS 对文档理解不很透彻,自己通过测试测到的执行顺序:
文档结构:
|-amaze
| -js
| -amazeui.js
| -jquery.min.js
| -main.js
| -test.js
| index.html
index.html
main.js
test.js
执行index.html页面,测试得出弹出顺序为:
head => body后 => test.js => main.js
文档结构:
|-amaze
| -js
| -amazeui.js
| -jquery.min.js
| -main.js
| -test.js
| index.html
index.html
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>商城首页</title> <script src="//cdn.bootcss.com/require.js/2.1.22/require.js" data-main="js/main"></script> </head> <script> alert("index-test前"); require(['test']); alert("index-test后"); </script> <body> <div id="css"></div> </body> <script> alert("body后"); </script> </html>
main.js
require.config({ paths:{ jquery:"jquery.min" }, shim:{ amazeui:{ deps:['jquery'] } } }) require(['jquery','amazeui'],function(){ alert("main") var a = '测试'; });
test.js
define(['jquery.min','amazeui','require'],function(){ alert("test"); console.log($("#css").css({'width':'200px','height':'200px','background':'red'})); });
执行index.html页面,测试得出弹出顺序为:
head => body后 => test.js => main.js
相关文章推荐
- 蓝牙技术BlueTooth
- Andrid Studio常用开发插件
- 【Vue】 -(7) 事件和方法
- UITabbarController的UITabbarItem(例:"我的")点击时,判断是否登录
- IOS7以上用UINavigationController 导致tableview下移解决方法
- 解决Maven更新后错误Dynamic Web Module 3.0 requires Java 1.6 or newer
- ValueAnimator的介绍与使用
- UIImage加载图片的方式以及Images.xcassets对于加载方法的影响
- UISegmentedControl
- cocoapods was not able to update the 'master' repo.if it is a unexpected issue and persists you can
- 自定义EasyUI下拉单选和下拉多选控件
- Null value was assigned to a property of primitive type setter of
- android source bluetooth
- How to retrieve the Device Unique ID from android device
- UI设计师的Photoshop配置技巧
- concurrent之BlockingQueue
- UITableView总结
- 【leetcode】128. Longest Consecutive Sequence
- duilib---响应windows原生消息和自定义消息
- 给UICollectionView添加表头