作业一:

用table表格标签渲染以上数据,表格第一列是学生总分排名,最后一列是学生总分

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <table border="1" style="margin: auto" rules="all">
        <tr>
            <th>排名</th>
            <th>姓名</th>
            <th>数学</th>
            <th>语文</th>
            <th>英语</th>
            <th>总分</th>
        </tr>
        <!--有几个人就循环渲染几行-->
        <tr v-for="(score,i) in scores">
            <td>{{i+1}}</td>
            <td v-for="v in score">{{v}}</td>
        </tr>
    </table>
</div>
</body>
<script src="js/vue.js"></script>
<script>
        let 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},
    ];
    //这里需要注意一点:for in遍历的是取值关键字而for of遍历的是值
    //添加总分
    for (score of scores) {
        score.total = score.math + score.chinese + score.english
    }
    //按照总分排序
    //这里使用的是冒泡算法
    for (let i = 0; i < scores.length - 1; i++) {
        for (let j = 0; j < scores.length - 1 - i; j++) {
            if (scores[j].total < scores[j + 1].total) {
                let temp = scores[j];
                scores[j] = scores[j + 1];
                scores[j + 1] = temp
            }
        }
    }
    console.log(scores);
    new Vue({
        el: '#app',
        data: {
            //属性名与值为变量名的变量名相同的时候,可以简写省略值
            scores,
        }
    })
</script>

</html>

作业二:

还是采用上方相同数据,采用相同的渲染规则,只渲染所有科目都及格的学生

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <table border="1" style="margin: auto" rules="all">
        <tr>
            <th>排名</th>
            <th>姓名</th>
            <th>数学</th>
            <th>语文</th>
            <th>英语</th>
            <th>总分</th>
        </tr>
        <!--有几个人就循环渲染几行-->
        <tr v-for="(score,i) in scores" v-if="score.math>=60&&score.chinese>=60&&score.english>=60">   <!--其实就是多加了一个if判断-->
            <td>{{i+1}}</td>
            <td v-for="v in score">{{v}}</td>
        </tr>
    </table>
</div>
</body>
<script src="js/vue.js"></script>
<script>
        let 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},
    ];
    //这里需要注意一点:for in遍历的是取值关键字而for of遍历的是值
    //添加总分
    for (score of scores) {
        score.total = score.math + score.chinese + score.english
    }
    //按照总分排序
    //这里使用的是冒泡算法
    for (let i = 0; i < scores.length - 1; i++) {
        for (let j = 0; j < scores.length - 1 - i; j++) {
            if (scores[j].total < scores[j + 1].total) {
                let temp = scores[j];
                scores[j] = scores[j + 1];
                scores[j + 1] = temp
            }
        }
    }
    console.log(scores);
    new Vue({
        el: '#app',
        data: {
            //属性名与值为变量名的变量名相同的时候,可以简写省略值
            scores,
        }
    })
</script>

</html>

作业三:采用相同的数据,添加筛选条件:
1、有三个按钮:数学,语文、外语,点击谁高亮,
2、两个输入框,【】~【】,前面小的分数,后面大分数,全部设置完毕,按照调钱筛选出对应的信息

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .active{
            background-color: chocolate;
        }
    </style>
</head>
<body>
<div id="app">
    <div style="width: 400px;margin: 20px auto;">
        <button @click="subject='math'" :class="{active: subject==='math'}">数学</button>
        <button @click="subject='chinese'" :class="{active: subject==='chinese'}">语文</button>
        <button @click="subject='english'" :class="{active: subject==='english'}">英语</button>
        <input type="number" min="0" max="100" v-model="min">
        ~
        <input type="number" min="0" max="100" v-model="max">

    </div>

    <table border="1" style="margin: auto" rules="all">
        <tr>
            <th>排名</th>
            <th>姓名</th>
            <th>数学</th>
            <th>语文</th>
            <th>英语</th>
            <th>总分</th>
        </tr>
        <tbody v-if="subject==='math'">
        <tr v-for="(score,i) in scores" v-if="score.math>=min && score.math<=max ||(!min||!max)">
            <td>{{i+1}}</td>
            <td v-for="v in score">{{v}}</td>
        </tr>
        </tbody>
        <tbody v-else-if="subject==='chinese'">
            <tr v-for="(score,i) in scores" v-if="score.chinese>=min && score.chinese<=max ||(!min||!max)">
                <td>{{i+1}}</td>
                <td v-for="v in score">{{v}}</td>
            </tr>
        </tbody>

        <tbody v-else-if="subject==='english'">
            <tr v-for="(score,i) in scores" v-if="score.english>=min && score.english<=max ||(!min||!max)">
                <td>{{i+1}}</td>
                <td v-for="v in score">{{v}}</td>
            </tr>
        </tbody>
          <tbody v-else=>
            <tr v-for="(score,i) in scores">
                <td>{{i+1}}</td>
                <td v-for="v in score">{{v}}</td>
            </tr>
        </tbody>

    </table>
</div>
</body>
<script src="js/vue.js"></script>
<script>
        let 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},
    ];
    //这里需要注意一点:for in遍历的是取值关键字而for of遍历的是值
    //添加总分
    for (score of scores) {
        score.total = score.math + score.chinese + score.english
    }
    //按照总分排序
    //这里使用的是冒泡算法
    for (let i = 0; i < scores.length - 1; i++) {
        for (let j = 0; j < scores.length - 1 - i; j++) {
            if (scores[j].total < scores[j + 1].total) {
                let temp = scores[j];
                scores[j] = scores[j + 1];
                scores[j + 1] = temp
            }
        }
    }
    console.log(scores);
    new Vue({
        el: '#app',
        data: {
            //属性名与值为变量名的变量名相同的时候,可以简写省略值
            scores,
            min:'',
            max:'',
            subject:'',
        }
    })
</script>

</html>

Vue习题作业练习的更多相关文章

  1. ECNU 计算机系统 (CSAPP) 教材习题作业答案集

    这里是华东师范大学计算机系统的作业答案.由于几乎每一年布置的习题都几乎相同,网上的答案又比较分散,就把自己上学期提交的作业pdf放上来了,供参考. 长这样 Download Link:http://c ...

  2. python习题作业合集(持续更新……)

    作业: 1.简述位,字节关系 2.请写出“天才”分别用utf-8和gbk编码所占位数 3.如果有一个变量num = 14,请使用int的方法,得到改变量最少可以用多少个二进制位表示 4.写代码,有如下 ...

  3. 《C++primer》v5 第1章 开始 读书笔记 习题答案

    从今天开始在博客里写C++primer的文字.主要以后面的习题作业为主,会有必要的知识点补充. 本人也是菜鸟,可能有不对之处,还望指出. 前期内容可能会比较水. 1.1略 1.2略 1.3 cin和c ...

  4. C#【结对编程作业】小学数学习题助手

    一.软件成品展示 软件本体下载(包括程序及其更新日志,源码工程包,UML图,API接口文档,算法介绍文档,算式计算excel实例,浅查重程序) 链接: http://pan.baidu.com/s/1 ...

  5. 機器學習基石(Machine Learning Foundations) 机器学习基石 作业三 课后习题解答

    今天和大家分享coursera-NTU-機器學習基石(Machine Learning Foundations)-作业三的习题解答.笔者在做这些题目时遇到非常多困难,当我在网上寻找答案时却找不到,而林 ...

  6. 機器學習基石 机器学习基石(Machine Learning Foundations) 作业1 习题解答 (续)

    这里写的是  习题1 中的    18 , 19, 20 题的解答. Packet 方法,我这里是这样认为的,它所指的贪心算法是不管权重更新是否会对train data有改进都进行修正,因为这里面没有 ...

  7. Linux系统管理----目录与文件管理作业习题

    chapter02 - 03 作业 1.  分别用cat \tac\nl三个命令查看文件/etc/ssh/sshd_config文件中的内容,并用自己的话总计出这三个文档操作命令的不同之处? cat ...

  8. vue作业2

    """ 2.现有以下成绩单数据 scores = [ { name: 'Bob', math: 97, chinese: 89, english: 67 }, { nam ...

  9. vue作业1

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

随机推荐

  1. 通过案例来剖析JQuery与原生JS

    首先来个例子: 我们在登陆或者注册一些网站时,如果某一项点过了但没填,鼠标移走后是不是经常看到网站有相应的红色字体提示呢? 那下面我们就以这个为例来剖析下jQuery和原生JS的一些区别,来上代码: ...

  2. Redis基础与持久化

    Redis介绍 软件说明 Redis是一款开源的,ANSI C语言编写的,高级键值(key-value)缓存和支持永久存储NoSQL数据库产品. Redis采用内存(In-Memory)数据集(Dat ...

  3. 查找担保圈-step5-比较各组之间的成员,对组的包含性进行查询,具体见程序的注释-版本2

    USE [test] GO /****** Object: StoredProcedure [dbo].[p03_get_groupno_e2] Script Date: 2019/7/8 15:01 ...

  4. 终于有人把“TCC分布式事务”实现原理讲明白了

    所以这篇文章,就用大白话+手工绘图,并结合一个电商系统的案例实践,来给大家讲清楚到底什么是 TCC 分布式事务. 首先说一下,这里可能会牵扯到一些 Spring Cloud 的原理,如果有不太清楚的同 ...

  5. Nginx的一些常用配置

    #定义Nginx运行的用户和用户组 #user nobody; #nginx进程数,建议设置为等于CPU总核心数. worker_processes 1; #全局错误日志定义类型,[ debug | ...

  6. Educational Codeforces Round 68 (Rated for Div. 2)补题

    A. Remove a Progression 签到题,易知删去的为奇数,剩下的是正偶数数列. #include<iostream> using namespace std; int T; ...

  7. SetIcon(m_hIcon, TRUE);的作用

    SetIcon(m_hIcon, FALSE);// Set small icon 这条语句,程序显示时,左上角就会显示定义了的图标,生成的EXE程序也显示了这个图标 SetIcon(m_hIcon, ...

  8. Django+celery+rabbitmq实现邮件发送

    一.环境 1.pip包 amqp==2.4.2 anyjson==0.3.3 billiard==3.6.0.0 celery==4.3.0 Django==2.2 dnspython==1.16.0 ...

  9. Java 多线程创建和线程状态

    一.进程和线程 多任务操作系统中,每个运行的任务是操作系统运行的独立程序. 为什么引进进程的概念? 为了使得程序能并发执行,并对并发执行的程序加以描述和控制. 因为通常的程序不能并发执行,为使程序(含 ...

  10. THUWC2020游记

    Day0 找了旅馆吃了东西才发现明天要去西郊宾馆,换旅馆?? 清华还安排住宿? asas了. 下午出去和kx&face报PKU的名.然后门卫不让进,老吕开启忽悠模式,然后很快就忽悠过去了.(我 ...