吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1469|回复: 4
收起左侧

[其他原创] JavaScript实现自定义基金涨跌网页

[复制链接]
hollsovan 发表于 2023-1-14 18:32
  • 自定义基金涨跌网页,可以根据需要自己添加基金代码即可。
  • 使用免费的基金api
  • 如果有个人网站或者GitHub的,可以部署到网站和GitHub上,随时随地查看基金涨跌情况。
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Funds</title>
    <link  rel="stylesheet"
          integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js"
            integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0"
            crossorigin="anonymous"></script>
</head>
<body style="padding-top: 20px">

<div class="d-flex justify-content-center">
    <div class="col-sm-8 col-md-10 col-lg-9 align-self-center">
        <h2 class="text-md-center">Funds</h2>
        <table class="table table-striped table-hover">
            <thead>
            <tr>
                <th scope="col">#</th>
                <th scope="col">代码</th>
                <th scope="col">名称</th>
                <th scope="col">日期</th>
                <th scope="col">单位净值</th>
                <th scope="col">涨跌</th>
            </tr>
            </thead>
            <tbody id="tbMain">

            </tbody>
        </table>
    </div>
</div>

<script>
    let tbody = document.getElementById("tbMain");
        // 这里设置需要的基金代码
    let code = ["009484", "003096", "013128", "320007", "005693", "012323"];
    let url = 'https://api.doctorxiong.club/v1/fund?code=' + code.join();

    fetch(url).then(response => response.json()).then(function (data) {
        let number = 1;
        [...data.data].map(function (x) {
            let tr = document.createElement("tr");
            tr.innerHTML = '<td>' + number + '</td>' +
                '<td>' + x.code + '</td>' +
                '<td>' + x.name + '</td>' +
                '<td>' + x.expectWorthDate + '</td>' +
                '<td>' + x.expectWorth + '</td>' +
                '<td>' + x.expectGrowth + '</td>'
            tr.style.color = x.expectGrowth > 0 ? 'red' : 'green';
            tbody.appendChild(tr);
            number++;
        })
    })
</script>
</body>
</html>


屏幕截图 2023-01-14 182743.png

免费评分

参与人数 1吾爱币 +5 热心值 +1 收起 理由
wushaominkk + 5 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

游水的猪 发表于 2023-1-15 10:29
免费接口应该不稳定
 楼主| hollsovan 发表于 2023-1-15 11:08
撒旦の恶 发表于 2023-1-17 10:25
感觉这单位净值可以弄成,今日估值和昨天净值的对比
a725 发表于 2023-1-20 09:49
感谢分享!
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-24 18:16

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表