<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>作业</title>
</head>
<body>
<div id="app">
    <h1 class="text-center">学生成绩总分排名表</h1>
    <table class="table table-hover">
        <thead>
        <tr>
            <th>姓名</th>
            <th>数学</th>
            <th>语文</th>
            <th>英语</th>
            <th>总分</th>
        </tr>
        </thead>
        <tbody>

        <tr v-for="dic in order_scores">
            <th>{{ dic['name'] }}</th>
            <th>{{ dic['math'] }}</th>
            <th>{{ dic['chinese'] }}</th>
            <th>{{ dic['english'] }}</th>
            <th>{{ dic['math']+dic['chinese']+dic['english'] }}</th>
        </tr>
        </tbody>
    </table>

    <h1 class="text-center">学生成绩及格表</h1>
    <table class="table table-hover">
        <thead>
        <tr>
            <th>姓名</th>
            <th>数学</th>
            <th>语文</th>
            <th>英语</th>
            <th>总分</th>
        </tr>
        </thead>
        <tbody>

        <tr v-for="dic in pass_score">
            <th>{{ dic['name'] }}</th>
            <th>{{ dic['math'] }}</th>
            <th>{{ dic['chinese'] }}</th>
            <th>{{ dic['english'] }}</th>
            <th>{{ dic['math']+dic['chinese']+dic['english'] }}</th>
        </tr>
        </tbody>
    </table>

    <h1 class="text-center">学生成绩查询表</h1>
    <p>
        <button type="button" @click="subject('math')">数学</button>
        <button type="button" @click="subject('chinese')">语文</button>
        <button type="button" @click="subject('english')">英语</button>
    </p>
    <p>请输入分数
        <input type="number" v-model="start" min="0" max="100">~
        <input type="number" v-model="end" min="0" max="100">
    </p>
    <table class="table table-hover">
        <thead>
        <tr>
            <th>姓名</th>
            <th :style="{backgroundColor: math}">数学</th>
            <th :style="{backgroundColor: chinese}">语文</th>
            <th :style="{backgroundColor: english}">英语</th>
            <th>总分</th>
        </tr>
        </thead>
        <tbody>
        <tr v-for="dic in scores">
            <th>{{ dic['name'] }}</th>
            <th :style="{backgroundColor: math}">{{ dic.math }}</th>
            <th :style="{backgroundColor: chinese}">{{ dic.chinese }}</th>
            <th :style="{backgroundColor: english}">{{ dic.english }}</th>
            <th>{{ dic['math']+dic['chinese']+dic['english'] }}</th>
        </tr>
        </tbody>
    </table>
</div>
</body>
<script src="js/vue.js"></script>
<script>
    new Vue({
        el: '#app',
        data: {
            scores: [
                {name: 'Bob', math: 97, chinese: 89, english: 67},
                {name: 'Tom', math: 67, chinese: 52, english: 98},
                {name: 'Jerry', math: 72, chinese: 87, english: 89},
                {name: 'Ben', math: 92, chinese: 87, english: 59},
                {name: 'Chan', math: 47, chinese: 85, english: 92},
            ],

            english: "",
            chinese: "",
            math: "",

            start: '',
            end: '',

            page: ''

        },
        methods: {
            subject(sub) {
                if (sub === "math") {
                    this.math = "red";
                    this.english = '';
                    this.chinese = '';
                } else if (sub === "english") {
                    this.english = "red";
                    this.math = "";
                    this.chinese = "";
                } else {
                    this.math = '';
                    this.english = '';
                    this.chinese = "red";
                }

            }
        },
        computed: {
            order_scores: function () {
                let arr = this.scores;

                for (let i = 0; i < arr.length; i++) {
                    for (let j = 0; j < arr.length - 1; j++) {
                        let sum1 = arr[j].math + arr[j].chinese + arr[j].english;
                        let sum2 = arr[j + 1].math + arr[j + 1].chinese + arr[j + 1].english;
                        if (sum1 < sum2) {
                            let temp = arr[j + 1];
                            arr[j + 1] = arr[j];
                            arr[j] = temp;
                        }
                    }
                }
                return arr
            },

            pass_score: function () {
                let arr = this.scores;
                let arr1 = [];
                for (let i = 0; i < arr.length; i++) {
                    if (arr[i].math >= 60 && arr[i].chinese >= 60 && arr[i].english >= 60) {
                        arr1[i] = arr[i]
                    }
                }

                return arr1
            },
        }

    })
</script>
</html>

最新文章

  1. 【ios开发】UITableViewCell的重用
  2. Redis JedisPool
  3. Flipboard-BottomSheetlayout 源码分析
  4. ubuntu10.04.4下安装JDK
  5. [转]IPTABLES中SNAT和MASQUERADE的区别
  6. 加载信息,先从数据库取出5条实现分页,鼠标向上滑动触发Ajax再加载5条,达到异步刷新,优化加载。。。
  7. Potocol Buffer详解
  8. mq_send
  9. 找不到类型或命名空间 datarowview
  10. git常用命令&lt;转&gt;
  11. Homestead PHP7安装phpredis扩展
  12. python制作爬虫爬取京东商品评论教程
  13. 第二次项目冲刺(Beta阶段)第一天
  14. 十大经典排序算法最强总结(含JAVA代码实现)
  15. Java 类加载机制 ClassLoder
  16. P2685 [TJOI2012]桥
  17. html页面的CSS、DIV命名规则(仅供参考学习)
  18. Linux中ls命令用法
  19. LSApplicationQueriesSchemes--关于info.plist 第三方登录 添加URL Schemes白名单
  20. VC++ 判断一个文件是不是快捷方式

热门文章

  1. MySQL 两张表关联更新(用一个表的数据更新另一个表的数据)
  2. JavaScript定时器(Timer)
  3. 如何快速找到多个字典中的公共键(key)
  4. n个数字相加
  5. nginx 修改文件上传大小限制
  6. 12. java ArrayList类
  7. 2019年全国高校计算机能力挑战赛 C语言程序设计决赛
  8. JS数组去除空值
  9. Oracle 11gR2中HR用户安装说明
  10. 女朋友会 Python 是多么可怕的一件事!