zoukankan      html  css  js  c++  java
  • day 68 作业

    '''
    有以下成绩单数据
    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 },
    ]
    用table表格标签渲染以上数据,表格第一列是学生总分排名,最后一列是学生总分;
    
    '''
    
    <!DOCTYPE html>
    <html lang="zh">
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <div id="d1">
            <table>
                <div>
                    <thead>
                        <tr>
                            <th>No.</th>
                            <th>name</th>
                            <th>math</th>
                            <th>chinese</th>
                            <th>english</th>
                            <th>sumScore</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr v-for="d in score">
                            <td></td>
                            <td>{{ d.name }}</td>
                            <td>{{ d.math }}</td>
                            <td>{{ d.chinese }}</td>
                            <td>{{ d.english }}</td>
                            <td>{{ d.ttlScore }}</td>
    
                        </tr>
                    </tbody>
                </div>
    
    
            </table>
        </div>
    </body>
    <script src="js/vue.js"></script>
    <script>
        new Vue({
            el: '#d1',
            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:'Chan',math:'47',chinese:'85',english:'92'}
                ]
    
            },
            filter: {
                sumScore(s1,s2,s3) {
                    return s1 + s2 + s3
                }
            },
            computed: {
                score() {
                    let scoreArr = this.scores;
                    for (let i = 0; i < scoreArr.length - 1; i++) {
                        for (let j = 0; j < scoreArr - 1 - i; j++) {
    
                            let currentScore = scoreArr[j].math + scoreArr[j].chinese + scoreArr[j].english;
                            let nextScore = scoreArr[j + 1].math + scoreArr[j + 1].chinese + scoreArr[j + 1].english;
                            scoreArr[j].ttlScore = currentScore;
                            scoreArr[j + 1].ttlScore = nextScore;
    
                            if (currentScore < nextScore) {
                                let temp = scoreArr[j];
                                scoreArr[j] = scoreArr[j + 1];
                                scoreArr[j + 1] = temp;
                            }
                        }
                    }
                    console.log(scoreArr);
                    return scoreArr
                }
            }
        });
    
    </script>
    </html>
    
  • 相关阅读:
    转:浅谈Linux的内存管理机制
    (转)Redis
    检测socket链接是否断开
    linux C 中的volatile使用
    LINUX 下 ipv6 socket 编程
    linux signal 列表
    Linux下异常信号
    linux signal
    转: 关于Linux常用的二进制文件分析方法
    IOI2020 题解
  • 原文地址:https://www.cnblogs.com/colacheng0930/p/12057958.html
Copyright © 2011-2022 走看看