Use html pages to implement simple algorithms and access through Baidu network disk

首先这篇博客主要是个思路,因为实现的方式有很多。
1.先讲下需求,这个需求本人经历,是这样的:假设有本金100000,那么多长时间会回本呢?
拿出计算机一条一条计算效率太低,而且本金变化的话还得重新算,于是想着写一个html页面进行算并且渲染出来。

2.代码逻辑相对并不是那么复杂,代码如下:
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
</head>
<body>
<div>
    总钱数:<input type="text" id="money">
    天数:<input type="text" id="day">
    <button id="search" onclick="calculate()">查询</button>
</div>
<div>
    计算出的结果:
    <ul id="result"></ul>
</div>
</body>
<script>
    function calculate() {
        var money = document.getElementById("money").value - 0;
        var day = document.getElementById("day").value - 0;
        var returnMoney = 0;
        //要进行渲染的div
        var result = document.getElementById("result");
        result.innerText = "";
        for(var i=1;i<=day;i++){
            var interest = money*0.001;
            interest = interest.toFixed(2) - 0;
            returnMoney = returnMoney + interest;
            returnMoney = returnMoney.toFixed(2) - 0;
            money = money.toFixed(2) - 0;
            money = money - interest;
            var li = document.createElement("li");
            li.innerText = '第'+i+'天;当天返息:'+interest+';总共返息:'+returnMoney+';剩余总金额:'+money;
            result.appendChild(li);
        }
    }
</script>
</html>

3. Save it as an html file, open it and use it directly. The screenshot of the effect is as follows:
write picture description here

4. The way to open html directly to the user is too low, and the ios side cannot open the html file on the WeChat side through the browser after testing. The simple solution is to put this file on the cloud server and then provide it to the user. Just visit. But not everyone has their own cloud server. After all, cloud servers still cost money. I will provide another free method here, which is to use Baidu cloud disk sharing to share this file, which can also achieve the effect of cloud server access. The following is the Baidu network disk sharing address:
https://pan.baidu.com/s/1jI3Wgom

5. Summary: After I finished it, I thought it was quite fun. I would like to share it with everyone. If there is any better way, you can leave me a message in time.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325577373&siteId=291194637