首页 > 其他分享 >Vue考试复习

Vue考试复习

时间:2023-06-12 10:13:35浏览次数:72  
标签:sumValue index none Vue 复习 margin padding border 考试

App.vue
<script setup>
import HelloWorld from './components/HelloWorld.vue'
import Login from './components/Login.vue'
// import Calc from './components/Calc.vue'
// import ShoppingCart from './components/ShoppingCart.vue'
</script>
<script>
export default{
  data(){
    return{
    
    };
  },
  components:{
    Login,
    // Calc,
    // ShoppingCart,
  }
}

</script>
<template>
  <Login></Login>
  <!-- <Calc></Calc> -->
  <!-- <ShoppingCart></ShoppingCart> -->
</template>

<style scoped>

</style>

登录页面

<script>
export default{
  data(){
    return{
      name:"",
      pass:"",
    };
  },
  methods:{
    check:function(){
      var name = this.name;
      var pass = this.pass;
      console.log(name+","+pass)
      if (pass.length < 6 || pass.length > 18) {
          alert("密码由6~18位的大小字母、数字、符号组成!")
      } else if (name == "admin" && pass == "123456" || name == "admin2" && pass == "456789") {
          alert("输入正确")
      } else {
          alert("用户名或密码错误!");
      }
    }
  }
}

</script>
<template>
 <form name="f" >
  <h1>登录页面</h1>
  <input type="text" id="name" placeholder="账号:admin" v-model="name"><br>
  <input type="password" id="pass" placeholder="密码:123456" v-model="pass"><br>
  <input type="button" @click="check()" value="登录">
    <div id="divp">
        <span>注册</span>
        <span>忘记密码</span>
    </div>
    <p>© 2023 MrFlySand</p>
  </form>
</template>

<style scoped>
h1{
  line-height: 3em;
}
form {
    text-align: center;
    position: absolute;
    /*表单于页面居中*/
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 0 40px;
    background: #eff6ff;
    padding: 20px 50px;
    border-radius: 10px;
}

input[type=text],
input[type=password] {
    background-color: rgba(0,0,0,0);
    /*正常状态样式*/
    color: black;
    border: none;
    outline: none;
    text-align: center;
    height: 50px;
    width: 250px;
    margin: 5px;
    border-bottom: 1px solid #626262;
}

input[type=button] {
    background-color: #45A0F2;
    /*正常状态样式*/
    color: white;
    border: none;
    border-radius: 20px;
    outline: none;
    text-align: center;
    height: 50px;
    width: 250px;
    margin: 50px 5px 20px 5px;
}

input[type=button]:hover {
    outline: none;

    background-color: #348dde;
    color: white;
}

#divp>span {
    color: #348dde;
    margin: 0 5px;
}

#divp span:active {
    text-decoration: underline;
}
</style>

购物车

<script>
export default{  
  data(){
    return{
      selectAllValue:1,
      priceSums:0,
      push:{
        name:null,
        price:null,
        count:null,
        prices:null,
      },
      list:[{
          checked:'false',
          name:'微信公众号',
          src:'https://mp.weixin.qq.com/mp/qrcode?scene=10000004&size=102&__biz=MzkzMjE5OTMwOA==&mid=2247487964&idx=1&sn=f7474b00c99bb7017530e4fbffd0c62d&send_time=',
          introduce:'扫码关注,和群友们一起交流学习',
          price:9999,
          count:2,
          prices:null,
      },
      {
          checked:'false',
          name:'QQ交流群',
          src:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAAAXNSR0IArs4c6QAAGmlJREFUeF7tnet2pDgMhJP3f+jZ06GZNbTEVyWb3Ebza89ibFmqkkqGJu9vb29/3hb9+/PHn+r9/T1cfZwrGkNrjffQXKMBzrzRfSvWpf06a2T72ecg39D9iu/u2k/khwxPVYg/0OmjOlmNwBXd1gTZvOIAtQmy+exTCVIBd2bkSARidAaMFfbsdtAaRFLawxnglAicvTnZN1rX2ftn2pVldCdRrPRzhtm/FcRxTjZZNAeBiwLolkYHUPvaTZDXKkZ+d/xMc2UyjdZogjiefY4lpzplmQik6O99TCaLaIvOfrqCxLKLfHy+Pvo8rCCzWV8BQ9Qk0kYo058lH82nVk1lP5TNVtlyJWuJTFHlV31A9ity241PJJHJDqc/UypXE4Q8njSDwm2HJpLGO0B1QECnUM66tAclkVDypSpYtYHWzaR+E4Q83gQRPLQNaYI8XUWNtZLhqKGP1lCyHckMuh7JkAwhZA9JQgVQJN3Ihmw/an81O/+VvlclFPmR9qhIu29RQQgQRCwlWEQAut4EOUJa8fl+B8U3Ayqt8esIooAsymBUmeRafxpIDiZ9qqxLFZG0NYFrhY3KPq6yupPAqva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wm2Msc+hkCvVJgmSI6EMkFm38WKAqewnEDvNMBRxlUAR5KQAOfsXQF4pWJWyU97o3kpKVWvOwmIQO88E8mq9vTbvA5IVp6dU3Zugjw1dPD3AceqXAVRlQB0XxPk6aGuIJocIEBRpqejzCbIq4dHn8nHvJSxH9fpaJaCSWBQbIjGEAiqWYtkE81L16v9F+3X8aNT9ckfyrp3reccJBzklvqg0N1cpKebIEcvNkE0GagkTsJWE+TCi5RRFaBSA12pnsq6JEUrFVNJdvuYuzJ61hTftd5SglBQHMBlwVBPkEbpthpQkQ1KtroCJfnOnb9CvAx87tpX4+mU0el9HLtW+lchY9iDkBFNkNeQriQbaXklUVDFc0CpVinCxdhTkSRyqlx1L00Q8NxKUK+cqwmSB46St0OWb0eQqlwg/eg4xcm+swcNtJYS7Arxqtk58iNJJcf3o1xWehDH/xWMKHv7VInVBDnCqQmy+cNJJBn5fxRBlKyigEOZJ8tKTqNK2jmz1cnUzn5nG+DMb06C2u1VZMi+ngNekpFq7O/utW6pIMrmHMDQfARUWqsJsnnYIWYUkybI0ysEKAL0uawq46/GNEFepYoKYNLhXUGe3+YlkGUArepHKuFVe6jRrJR2qkBj9iV/KMmhCkrHp7QnOhwguUYyT/GTkzijvSuYpTW+7F0sJ5i0Cbo+20MQmJogWgVz/URxHa83QRxvncY2QfIew8n0VH1XJxIn5LcTxDGGnKqUtqiEO02eI8EcgtBxIWl2AlFVYin7rdju7EfZ2z6GJJQSEwJ9tAatO/pfwdstP5hqgrxm7EgOKImGQELz0oFKE+Q1CqNPmiCCHCOQZVVByVARSei4VUlA+xiyvQlyTZD/AFIQv65aF8OXAAAAAElFTkSuQmCC',
          introduce:'',
          price:6666,
          count:1,
          prices:null,
      },
      { 
          checked:'false',
          name:'MacBookPro',
          src:'https://img10.360buyimg.com/n2/jfs/t1/203950/20/28591/140129/637ca996E10cf6f5c/bb31749afd714364.jpg',
          introduce:'',
          price:21488,
          count:1,
          prices:null,
      }],    
    }
  },
  computed:{
    // 计算总和
    priceSums:function(){
      var sum = 0;
      for(var i = 0; i != this.list.length; i++){
        if(this.list[i].checked == true){
          sum = sum + this.list[i].price * this.list[i].count;
        }   
      }
      return sum;
    }
  },
  methods:{
    //减少物品个数
    reduce:function(index){
      this.list[index].count = this.list[index].count - 1;
      if(this.list[index].count == -1){
        this.list.splice(index,1)
      }
    },
    // 增加物品个数
    add:function(index){
      this.list[index].count = this.list[index].count + 1;
      return "this.list[index].count";  
    },
    // 添加新元素在购物车中
    pushValue:function(){    
      console.log(this.push.name)
      if(this.push.name == undefined) return 0;  
      for(var i=0; i<this.list.length; i++){
        if(this.list[i].name == this.push.name){
          alert("你已勾选此产品");
          return 0;
        }
      }
      this.list.push(this.push);
      this.push = {name:'', price:null, count:null};
    },
    // 选中所有
    selectAll:function(){
      for(var i=0,j=0; i<this.list.length; i++){
        if(this.list[i].checked == true){
          if(i==j){
            for(var k=0; k<this.list.length; k++){
              this.list[k].checked = false;
            }
            this.selectAllValue = false;
            return 0;    
          }
          j++;
        }
        this.list[i].checked = true;
      }
      this.selectAllValue = true;
    },
    // 删除选中
    selectDel:function(){
      if(confirm("你确认要删除吗?","提示框 ")){
        for(var i=0; i<this.list.length; i++){
          if(this.list[i].checked == true){
            this.list.splice(i,1);
          }
        }
      }
    },
    // 搜索
    // str.replace(/\ +/g,"") 清除空格
    search:function(){
      var str = "aaabc"
      console.log(str.includes("d"))
      var str = this.searchText.replace(/\ +/g,"")
      for(var i=0; i<this.list.length; i++){
        var nowStr = this.list[i].name.replace(/\ +/g,""); 
        if(str==nowStr || nowStr.includes(str)){
          this.list.unshift(this.list[i]);
          this.list.splice(i+1,1);
        }
      }
    }
  }
}
</script>

<template>
  
  <table id="ShoppingCart">
    <div id="search">
      <input id="searchText" v-model="searchText" type="text" placeholder="搜索" >
      <button @click="search">搜索</button>
    </div>
    <!-- 表头 -->
    <tr style="font-weight: 800;">
      <td>序号</td>
      <td>商品</td>
      <td>单价(元)</td>
      <td>数量</td>
      <td>金额(元)</td>
    </tr> 

    <!-- 商品表 -->
    <tr v-for="(value,index) in list">
      <td><input type="checkbox" v-model="value.checked"></td>
      <td>
        <img v-bind:src="value.src" alt="图片" id="commodityImg">
        <span>{{value.name}}</span>
        <span style="font-size: 0.8em; color: #919191;">{{value.introduce}}</span>  
      </td>
      <td style="color: #e00000;">¥{{ value.price }}</td>
      <td style="padding: 0 !important;">
        <button @click="reduce(index)">-</button>
        <input type="text" v-model="value.count">
        <button @click="add(index)">+</button>
      </td>
      <td style="color: #e00000;font-weight: 800;">¥{{value.price*value.count}}</td>
    </tr>

    <!-- 添加商品 -->
    <tr id="add">
      <td></td>
      <td><input type="text" v-model="push.name" placeholder="商品"></td>
      <td><input type="text" v-model="push.price" placeholder="价格"></td>
      <td><input type="text" v-model="push.count" placeholder="数量"></td>
      <td><button id="push" @click="pushValue">添加</button></td>
    </tr>

    <!-- 全选、删除、合计等操作 -->
    <tr>
      <td colspan="2">
        <div @click="selectAll" ><input type="checkbox" v-model="selectAllValue">全选</div>
        <div @click="selectDel" >&nbsp;&nbsp;删除</div>
      </td>
      <td colspan="3">
        合计:<p style="color: #e00000;font-weight: 800;padding: 0.6em 0em; display: contents;">¥{{priceSums}}</p></td> 
    </tr>
  </table>
</template>


<style>
*{
  padding: 0; margin: 0;
}
 button{
  /* margin-bottom: 10px !important; */
  /* border:1px solid #ccc; */
  width: 100%;
  height:100%;
  margin:0;
  padding: 0;
  border-radius: 0px;
}
 #commodityImg{
  border:1px solid #000;
  margin-right:10px;
}
 table{
  border:none;
  border-block: 4px solid #ccc;
  writing-mode: horizontal-tb;
  font-size: 1rem;
}
 tr>td{
  border:1px solid #fff;
  padding:15px 10px;margin: 0;
  height: 40px !important;
}
 tr>td:nth-child(2){
  width: 400px;
}
tr>td:nth-child(2)>img{
  width: 100px;
  float: left;
  display: block;
}
tr>td:nth-child(2)>span{
  display: flex;
}
tr>td:nth-child(4)>button,tr>td:nth-child(4)>input{
  width: 60px;height: 30px;
  border: none;
}
tr:last-child>td>div{
  display: inline;
  float: left;
  margin:0;padding:0 !important;
}
tr{
  padding:10px 20px;
  display: block;
  border-block-start:2px solid #ccc; 
  writing-mode: horizontal-tb;
}
#push{
  margin: 0px !important;
  width: 100%;
  display: block;
  border: none;
  padding: 3px 15px;
}
input{
  border: none;
  text-align: center;
}

#add{
  font-weight: 800 !important;

}
#add input{
  height: 100%;
  border:1px solid #ccc;
}
#add input:active{
  border:1px solid #ccc !important;
}
#search{
  border: #000 solid 1px;
  padding: 0 !important;
  margin: 20px 0;
}
#searchText{
  margin: 2px 8px !important;
  font-size: 16px;
}
#search input{
  width: 90%;
  padding: 5px 8px;
  border: none !important;
  user-select: none;
  outline: none;
}

#search button{
  width:auto;
  padding: 5px 8px;
  outline: none;
  float: right;
  border: none;
  margin: auto 0;
}
#search button:active{
  background-color: #ddd;
}
</style>

计算器

<script>
export default{
    data(){
        return{
            sumValue:"0",
            arr:[["x<sup>2</sup>","1/x","C","✖"],[7,8,9,"/"],[4,5,6,"*"],[1,2,3,"-"],[".",0,"=","+"]]        
        };
    },
    methods:{
        getSum:function(index,i){
            console.log(index+":"+i)
            if(index==0 && i==0){
                console.log(Math.pow(this.sumValue,2));
                this.sumValue = Math.pow(this.sumValue,2);
            }else if(index==0 && i==1){
                console.log(this.sumValue)
                this.sumValue = 1.0/this.sumValue;                    
            }else if(index==0 && i==2){
                this.sumValue = 0;                    
            }else if(index==0 && i==3){        
                this.sumValue = this.sumValue.substring(0, this.sumValue.length - 1);;                    
            }else if(index==4 && i==2){
                this.sumValue = "结果:"+eval(this.sumValue);            
            }else if(this.sumValue == '0' || this.sumValue[0]=="结"){
                this.sumValue = this.arr[index][i].toString();
            }else if(this.sumValue != '0' && this.arr[index][i].toString()!="="){                
                this.sumValue = this.sumValue + this.arr[index][i].toString();
            }            
        },
    }
}
</script>
<template>
    <table id="calc">
        <tr>
            <td colspan="4" style="padding: 0">
                <input type="text" v-model="sumValue">
            </td>
        </tr>
        <tr v-for="(value,index) in arr" :key="value">
            <td  v-for="(val,i) in value" :key="val" @click="getSum(index,i)"  @keyup.enter="print(index,i)" v-html="val"></td>
        </tr>        
    </table>
</template>
<style>
*{
    padding: 0;margin: 0;
}
table{
    /* border: 2px solid #000; */
    user-select: none;
    background-color: #eeeeee;
}
table td{
    /* border: 1px solid #000; */
    padding: 3px 16px;
    background: #fff;
}
table td:hover{
    background-color: #eee;
}
table td:active{
    background-color: #ddd;
    
}
table tr:nth-child(1) td:hover{
    background-color: #fff;
}
input{
    border: none;
    padding-top: -10px;
    text-align: right;
    outline: none;

}
</style>

标签:sumValue,index,none,Vue,复习,margin,padding,border,考试
From: https://www.cnblogs.com/MrFlySand/p/17474173.html

相关文章

  • Javascript考试复习
    登录页面<!DOCTYPEhtml><html><head><metacharset="utf-8"><title>登录页面</title><style>html{background:#bde0ff;}form{text-align......
  • springboot+vue留守儿童爱心网站,附源码+数据库+论文+PPT,远程包安装运行
    1、项目介绍留守儿童爱心网站采用了B/S结构,JAVA作为开发语言,数据库采用了B/S结构,Mysql数据库进行开发。该系统包括前台操作,后台由管理员和用户两个部分,一方面,为用户提供首页、宣传新闻、志愿活动、爱心捐赠、个人中心、后台管理等功能;另一方面,为管理员提供首页、个人中心、用户管......
  • 前端 vue 自定义导航栏组件高度及返回箭头 自定义 tabbar 图标
    前端vue自定义导航栏组件高度及返回箭头自定义tabbar图标,下载完整代码请访问uni-app插件市场地址:https://ext.dcloud.net.cn/plugin?id=12986效果图如下:使用方法//page.json采用矢量图标设置返回箭头,{"path":"pages/Home/Home",......
  • 掌握Vue生命周期,让你的前端开发效率翻倍!
    1Vue实例<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>Vue实例</title><scriptsrc='../vue.js'></script></head><body><......
  • Vue3.js第一部分【核心篇】
    Vue3Vue核心Vue3快速上手​1.Vue3简介2020年9月18日,Vue.js发布3.0版本,代号:OnePiece(海贼王)耗时2年多、​2600+次提交、30+个RFC、600+次PR、99位贡献者github上的tags地址:​https://github.com/vuejs/vue-next/releases/tag/v3.0.0国内官网地址:​Vue.js-渐进式JavaScr......
  • [Vue warn]: Error compiling template: Component template should contain exactly
    报错信息:[Vuewarn]:Errorcompilingtemplate:Componenttemplateshouldcontainexactlyonerootelement.Ifyouareusingv-ifonmultipleelements,usev-else-iftochaintheminstead.2|3|4||......
  • 计算机网络原理复习
    教材:计算机网络——自顶向下方法(第七版)作者:JamesF.Kurose,KeithW.Ross内容0-2在复述书6.7节0.数据的获得以访问网站为例。现在Bob(人在美国)要访问www.google.com这个网站!他所需要的是:他自己的IP地址、google的IP地址在获取的过程中,他还要用到:DNS服务器地址、本......
  • Vue_Django 登录注册+图书管理系统
    Vue前端注册页面点击查看代码<template><divclass="register"><el-row:gutter="20"><el-col:span="12":offset="6"><divclass="grid-contentbg-purple">&......
  • Spring Boot&Vue3前后端分离实战wiki知识库系统<八>--分类管理功能开发二
    接着上一次SpringBoot&Vue3前后端分离实战wiki知识库系统<七>--分类管理功能开发的分类功能继续完善。分类编辑功能优化:概述:现在分类编辑时的界面长这样:很明显目前的父分类的展现形式不太人性,这里需要指定父分类的id才可以,对于用户来说这种交互是反人道的,用户怎么知道父分类......
  • 高考试题
    \begin{Example}(2010年广东)设$A(x_1,y_1),B(x_2,y_2)$是平面直角坐标系$xOy$上的两点,现定义由点$A$到点$B$的一种折线距离$\rho(A,B)$为$\rho(A,B)=|x_2-x_1|+|y_2-y_1|$.对于平面$xOy$上给定的不同的两点$A(x_1,y_1),B(x_2,y_2)$.\begin{enumerate}\item[(I)]若点$C(x,y)$......