<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<style>
.box {
width: 200px;
height: 200px;
background-color: black;
}
.red{
background-color: red;
}
.yel{
background-color: yellow;
}
.blue{
background-color: blue;
}
</style>
</head>
<body>
<div id="d1">
<div :class="['box',{red:is_true,yel:is_true1,blue:is_true2}]" ></div>
<button @click="f1">{{red}}</button>
<button @click="f2">{{yel}}</button>
<button @click="f3">{{blue}}</button>
</div> </body>
<script src="bootstrap-3.3.7-dist/vue.min.js"></script>
<script>
new Vue({
el:'#d1',
data:{
is_true:false,
is_true1:false,
is_true2:false,
red:'红色',
yel:'黄色',
blue:'蓝色',
},
methods:{
f1(){
this.is_true=1;
this.is_true1=0;
this.is_true2=0;
},
f2(){
this.is_true1=1;
this.is_true=0;
this.is_true2=0; },
f3(){
this.is_true2=1;
this.is_true1=0;
this.is_true=0;
}
} }); </script>
</html>
### 作业二:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<style>
.box {
width: 200px;
height: 200px;
background-color: black;
}
.pink{
background-color: pink;
}
.green{
background-color: green;
}
.cyan{
background-color: cyan;
}
</style>
</head>
<body> <div id="d2">
<div :class="['box',{pink:is_true,green:is_true1,cyan:is_true2}]" @click="f1($event)"></div>
</div>
</body>
<script src="bootstrap-3.3.7-dist/vue.min.js"></script>
<script>
new Vue({
el:'#d2',
data:{
is_true:false,
is_true1:false,
is_true2:false,
},
methods: {
f1(e){
let time=1;
if(e.detail===time){
this.is_true = 1;
this.is_true1 = 0;
this.is_true2 = 0;
console.log(time)
}if(e.detail===time+1){
this.is_true = 0;
this.is_true1 = 1;
this.is_true2 = 0;
}if (e.detail===time+2) {
this.is_true = 0;
this.is_true1 = 0;
this.is_true2 = 1; } }
}
})
</script>
</html>

VUEday01的更多相关文章

  1. vue---day01

    1.let和const var 全局作用域和函数作用域 存在变量提升 其实是个bug 可以重复声明 let 块级作用域 不存在变量提升 不能重复声明 const 常量 和let一样还有另外两个 定义的 ...

随机推荐

  1. React传值,验证值的类型和默认值

    const ele = <Ff const={'哈哈'} index={55}></Ff> let box = document.querySelector('#app') / ...

  2. 更改input标签的placeholder的样式

    主要是要区别不同浏览器的不同css类 在input框中有时想将输入的字和placeholder设为不同的颜色或其它效果,这时就可以用以下代码来对placeholder进行样式设置了. input::- ...

  3. vim的查找功能

    vim是一款强大的编辑器. 在vim下要查找字符串: 一,全匹配: 1,从上往下查找,比如“string” :   /string 2,从下往上查找,比如“string” : ?string 二,模糊 ...

  4. canvas入门,就是这个feel!

    钙素 Canvas 是在HTML5中新增的标签用于在网页实时生成图像,并且可以操作图像内容,基本上它是一个可以用JavaScript操作的位图.也就是说我们将通过JS完成画图而不是css. canva ...

  5. Excel导入数据库(php版)

    一.环境说明 Apache+php(PHPExcel)+HTML5+JavaScript(jQuery)+MySQL 二.前端预览 三.Excel表格 四.HTML部分 <p>按照Exce ...

  6. web前端之css基础

    CSS选择器 元素选择器 p{color:red;} ID选择器 #li{ background-color:red; } 类选择器 .c1{ font-size:15px; } 注意: 样式类名不要 ...

  7. 30L,17L,13L容器分油,python递归,深度优先算法

    伪代码: 全部代码: a=[] b=[] def f(x,y,z): b.append([x,y,z]) if x==15 and y==15: print(x,y,z) i=0; for x in ...

  8. selenium处理隐藏元素的方法

    <li class="navbar-nav-item ">       <a href="#" id="cust"> ...

  9. PHP安装sodium加密扩展

    1.为什么会用到sodium加密扩展? 最近在做微信服务商相关的开发,主要用的的接口为微信小微商户进件接口.在请求相关接口中,需要对一些敏感字段进行加密,加密过程见https://pay.weixin ...

  10. Xtrabackup 增量备份 和 增量还原

    目录 测试数据准备 进行全量备份 第一次增量插入一条数据 进行第一次增量备份 注意 第二次增量插入一条数据 进行第二次增量备份 注意 查看xtrabackup_binlog_info中的binlog位 ...