You will typically use a data-main script to set configuration options and then load the first application module. Note: the script tag require.js generates for your data-main module includes the async attribute. This means that you cannot assume that the load and execution of your data-main script will finish prior to other scripts referenced later in the same page.

翻译:通常会使用data-main设置的脚本里写一些配置选项,然后读取你配置里的第一个程序模块,注意require.js生成的data-main模块里的配置包含异步属性,注意你无法确定在同一个页面里面,你的data-main设置的脚本会在你其他脚本之前运行完,其他就是只的在文件位置上data-main后面的脚本

script data-main="scripts/main" src="scripts/require.js"></script>
<script src="scripts/other.js"></script>---》这个就是其他所指的文件

For example, this arrangement will fail randomly when the require.config path for the 'foo' module has not been set prior to it being require()'d later:

例如这个写法就会很容易造成问题,require.config配置的这个path属性没有在require()执行前设置,而是是在他执行后设置

<script data-main="scripts/main" src="scripts/require.js"></script>--》标签1
<script src="scripts/other.js"></script>--》标签2 // contents of main.js:
require.config({
paths: {
foo: 'libs/foo-1.1.3'
}
}); // contents of other.js: // This code might be called before the require.config() in main.js-》
// has executed. When that happens, require.js will attempt to-》
// load 'scripts/foo.js' instead of 'scripts/libs/foo-1.1.3.js'
//翻译:下面的代码或许在require.config()执行之前就被调用了,
//会造成require.js会加载script目录下的foo.js。而不是scripts/libs下的foo-1.1.3,
//在不设置baseUrl情况下requirejs会默认加载引用了requirejs文件所在的目录里的模块-》src="scripts/require.js"的
//总结就是说 不要以为标签2在标签1下面。标签1里的东西就会执行完
require( ['foo'], function( foo ) { });


RequireJs学习笔记之data-main Entry Point的更多相关文章

  1. C# 动态生成word文档 [C#学习笔记3]关于Main(string[ ] args)中args命令行参数 实现DataTables搜索框查询结果高亮显示 二维码神器QRCoder Asp.net MVC 中 CodeFirst 开发模式实例

    C# 动态生成word文档 本文以一个简单的小例子,简述利用C#语言开发word表格相关的知识,仅供学习分享使用,如有不足之处,还请指正. 在工程中引用word的动态库 在项目中,点击项目名称右键-- ...

  2. Hadoop源码学习笔记(2) ——进入main函数打印包信息

    Hadoop源码学习笔记(2) ——进入main函数打印包信息 找到了main函数,也建立了快速启动的方法,然后我们就进去看一看. 进入NameNode和DataNode的主函数后,发现形式差不多: ...

  3. [C#学习笔记3]关于Main(string[ ] args)中args命令行参数

    Main(string[] args)方法是C#程序的入口,程序从这里开始执行,在这里结束.C#代码逻辑要包含在一个类型(Type)中,游离的.全局的变量或函数是不存在的,这里的类型包括类(class ...

  4. 学习笔记之Data analysis

    Data analysis - Wikipedia https://en.wikipedia.org/wiki/Data_analysis Data analysis is a process of ...

  5. 学习笔记之Data Visualization

    Data visualization - Wikipedia https://en.wikipedia.org/wiki/Data_visualization Data visualization o ...

  6. 学习笔记之Data Science

    Data science - Wikipedia https://en.wikipedia.org/wiki/Data_science Data science, also known as data ...

  7. RequireJS学习笔记

    前言 进入移动前端是很不错的选择,这块也是我希望的道路,但是不熟悉啊... 现在项目用的是require+backbone,整个框架被封装了一次,今天看了代码搞不清楚,觉得应该先从源头抓起,所以再看看 ...

  8. RequireJS学习笔记(转)

    前言 进入移动前端是很不错的选择,这块也是我希望的道路,但是不熟悉啊... 现在项目用的是require+backbone,整个框架被封装了一次,今天看了代码搞不清楚,觉得应该先从源头抓起,所以再看看 ...

  9. EnterpriseLibrary 6.0(微软企业库6.0学习笔记) 之Data Access Block 配置和获取链接字符串

    EnterpriseLibrary 的特点是快速开发,融合了微软工程师多年的经验,现在在微软内部有专门的一个小组在完善EnterpriseLibray,最近的更新时间是April 2013. 相关链接 ...

随机推荐

  1. c语言和java以及安卓和苹果

    苹果手机是本地,没有中间环节,速度快,基于Linux系统 安卓是通过虚拟机,影响速度 就像c语言和java c适用于架构小的地方,因为直接编译运行 而java用于架构比较大的地方,启动慢,启动之后效率 ...

  2. Javascript原型与对象等知识

    声明式函数定义: function add(m,n) { alert(m+n); } 这种方式等同于构造一个Function类的实例的方式: var add = new Function(" ...

  3. 加载log文件

    procedure Jslog(szLogText:string);var pMyFile : TextFile;begin Assignfile(pMyFile, 'log.txt'); if Fi ...

  4. [LeetCode 题解]: Maximum Depth of Binary Tree

    Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...

  5. C#在线运行

    初步完成c#代码的在线编辑.       首先,传回前端的c#在线代码,进行预编译,用CSharpCodeProvider这个方法.设置编译版本3.5 设置编译参数GenerateInMemory:是 ...

  6. Consul KV

    Consul之:key/value存储 key/value作用 动态修改配置文件 支持服务协同 建立leader选举 提供服务发现 集成健康检查 除了提供服务发现和综合健康检查,Consul还提供了一 ...

  7. centos 7 安装mysql5.6rpm格式

    1查看是否安装了mysql   rpm -qa|grep -i mysql 如果安装了请卸载:rpm -e --nodeps MySQL... 2.没有安装则进行如下操作 下载mysql rpm ta ...

  8. SFML从入门到放弃(0) 配置环境

    SFML从入门到放弃(0) 配置环境 恩..开始划水..学sfml的时候顺便做点笔记什么的.. 安装 在linux里面打开终端 然后输入 sudo apt-get install libsfml-de ...

  9. sed--行编辑器命令

    2017-11-02 sed:行编辑器,按行处理:默认不做原文件修改,会在sed自身的模式空间中按行读相关的数据并完成编辑,然后显示到屏幕上     一.     基本用法: 1. 语法格式: sed ...

  10. 使用ls,du命令进行文件排序

      一. 使用du命令进行大小排序   du -h --max-depth=1 | sort -hr 参数说明: --max-depth:表示要查看几层目录 sort -r:反向显示 sort -h: ...