简体   繁体   English

将配置值传递给JS文件

[英]Pass In Config Values to JS File

I have a JavaScript file, and I would like to pass in a few config values to my JS file. 我有一个JavaScript文件,我想将一些配置值传递给我的JS文件。 I originally thought of using an .INI file, but I found out that the browser cannot access these System Config values. 我本来以为使用.INI文件,但是我发现浏览器无法访问这些系统配置值。 Does anyone have any suggestions to alternatives? 有人对替代品有什么建议吗?

I store my configuration in a separate JSON file and load that into the app as a configuration object. 我将配置存储在单独的JSON文件中,并将其作为配置对象加载到应用中。

See this answer for examples on how to do this using Require.js or jQuery: requirejs load static JSON file 有关如何使用Require.js或jQuery的示例,请参见以下答案: requirejs加载静态JSON文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM