【问题标题】:How to pass parameter from a .properties file to an HTML page如何将参数从 .properties 文件传递​​到 HTML 页面
【发布时间】:2016-01-18 08:27:38
【问题描述】:

问候堆垛者, 我有一个包含键值对的属性文件“demo.properties”: Build=47

我还有一个 HTML(静态)页面 'demo.html'

<html>
<body>
The current build is:  <!--here I want the value of build from the demo.properties -->
</body>
</html>

有没有办法在这里访问 'Build' 的值?任何建议将不胜感激。谢谢!

【问题讨论】:

    标签: html properties-file


    【解决方案1】:

    您可以使用 javascript 来读取您的文件,然后将从 demo.properties 文件中读取的文本拆分为“=”以获得构建版本。

    var readFile = function(event) {
      var input = event.target;
      var reader = new FileReader();
      reader.onload = function() {
        var result = reader.result;
        var outputDiv = document.getElementById('output');
        outputDiv.innerText = "The current build is: " + result.split("=")[1];
      };
      reader.readAsText(input.files[0]);
    };
    

    工作 plnkr 是:Plnkr

    【讨论】:

      猜你喜欢
      • 2020-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多