{"action":"created","issue":{"url":"https://api.github.com/repos/seajs/seajs/issues/1277","labels_url":"https://api.github.com/repos/seajs/seajs/issues/1277/labels{/name}","comments_url":"https://api.github.com/repos/seajs/seajs/issues/1277/comments","events_url":"https://api.github.com/repos/seajs/seajs/issues/1277/events","html_url":"https://github.com/seajs/seajs/issues/1277","id":38693995,"number":1277,"title":"seajs data vars的用法","user":{"login":"fwon","id":2664632,"avatar_url":"https://avatars.githubusercontent.com/u/2664632?v=3","gravatar_id":"","url":"https://api.github.com/users/fwon","html_url":"https://github.com/fwon","followers_url":"https://api.github.com/users/fwon/followers","following_url":"https://api.github.com/users/fwon/following{/other_user}","gists_url":"https://api.github.com/users/fwon/gists{/gist_id}","starred_url":"https://api.github.com/users/fwon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fwon/subscriptions","organizations_url":"https://api.github.com/users/fwon/orgs","repos_url":"https://api.github.com/users/fwon/repos","events_url":"https://api.github.com/users/fwon/events{/privacy}","received_events_url":"https://api.github.com/users/fwon/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2014-07-25T03:11:51Z","updated_at":"2015-01-29T05:23:13Z","closed_at":"2014-07-29T06:58:27Z","body":"我们知道vars是用在require('xxx/{vars}');中的。用于动态配置url。\r\n但是是否有场景可以为seajs注入全局变量，而不想直接暴露给外部。由于use中的模块是预加载后再执行回调的，所以app.js中想要用到变量globalName, 则需要在它的前面定义该变量。如：\r\n```\r\nseajs.config({\r\n vars: {\r\n  globalName: 'hehe'\r\n }\r\n});\r\nseajs.use([app], function(App){\r\n  //do something\r\n});\r\n```\r\n在app.js中使用全局变量:\r\n```\r\ndefine(function (require, exports, module) {\r\n console.log(seajs.data.vars.globalName);\r\n});\r\n```\r\n这种做法虽然可行，但是不是合理的？或者有其他解决方案？"},"comment":{"url":"https://api.github.com/repos/seajs/seajs/issues/comments/71970929","html_url":"https://github.com/seajs/seajs/issues/1277#issuecomment-71970929","issue_url":"https://api.github.com/repos/seajs/seajs/issues/1277","id":71970929,"user":{"login":"andyforever","id":3242791,"avatar_url":"https://avatars.githubusercontent.com/u/3242791?v=3","gravatar_id":"","url":"https://api.github.com/users/andyforever","html_url":"https://github.com/andyforever","followers_url":"https://api.github.com/users/andyforever/followers","following_url":"https://api.github.com/users/andyforever/following{/other_user}","gists_url":"https://api.github.com/users/andyforever/gists{/gist_id}","starred_url":"https://api.github.com/users/andyforever/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andyforever/subscriptions","organizations_url":"https://api.github.com/users/andyforever/orgs","repos_url":"https://api.github.com/users/andyforever/repos","events_url":"https://api.github.com/users/andyforever/events{/privacy}","received_events_url":"https://api.github.com/users/andyforever/received_events","type":"User","site_admin":false},"created_at":"2015-01-29T05:23:13Z","updated_at":"2015-01-29T05:23:13Z","body":"Sea.js推荐如何使用全局变量？"}}