vue作业1
2024-10-07 04:14:16
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>exercise</title>
<style>
.abc{
width: 200px;
height: 200px;
}
.green{
background-color: green;
}
.red{
background-color: red;
}
.blue{
background-color: blue;
}
</style>
</head>
<body>
<div id="id1">
<div>
<input type="button" class="btn1 " @click="change_color1">
</div>
<div>
<input type="button" class="btn2 " @click="change_color2">
</div>
<div>
<input type="button" class="btn3 " @click="change_color3">
</div>
<div :style="myStyle1" id="id2">box</div>
</div>
</body>
<script src="vue.js"></script>
<script>
new Vue({
el:'#id1',
data:{
myStyle1: {
width: '200px',
height: '200px',
backgroundColor: 'orange'
},
},
methods:{
change_color1(){
this.myStyle1.backgroundColor = 'green'
},
change_color2(){
this.myStyle1.backgroundColor = 'red'
},
change_color3(){
this.myStyle1.backgroundColor = 'blue'
},
}
})
</script>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>exercise</title>
</head>
<body>
<div id="id1">
<div>
<input type="button" class="btn1 " @click="change_color1">
</div>
<div :style="myStyle1" id="id2" >{{ num }}</div>
</div>
</body>
<script src="vue.js"></script>
<script>
new Vue({
el:'#id1',
data:{
num:0,
color:['pink','cyan','green'],
myStyle1: {
width: '200px',
height: '200px',
backgroundColor: 'orange'
},
},
methods:{
change_color1(){
this.num += 1;
color1 = this.num%3;
console.log(color1);
this.myStyle1.backgroundColor = this.color[color1];
}
}
})
</script>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>exercise</title>
<style>
.abc{
width: 200px;
height: 200px;
}
.green{
background-color: green;
}
.red{
background-color: red;
}
.blue{
background-color: blue;
}
</style>
</head>
<body>
<div id="id1">
<div>
<input type="button" class="btn1 " @click="change_color1">
</div>
<div>
<input type="button" class="btn2 " @click="change_color2">
</div>
<div>
<input type="button" class="btn3 " @click="change_color3">
</div>
<div :style="myStyle1" id="id2">box</div>
</div>
</body>
<script src="vue.js"></script>
<script>
new Vue({
el:'#id1',
data:{
myStyle1: {
width: '200px',
height: '200px',
backgroundColor: 'orange'
},
},
methods:{
change_color1(){
this.myStyle1.backgroundColor = 'green'
},
change_color2(){
this.myStyle1.backgroundColor = 'red'
},
change_color3(){
this.myStyle1.backgroundColor = 'blue'
},
}
})
</script>
</html>
最新文章
- sql筛选查询A表中B表已经存在的数据
- 【抓包工具】wireshark
- 关于Blender
- swiper 技巧
- jQuery.lazyload详解
- c#委托(1)
- XML到底是什么
- Visual Studio 不生成.vshost.exe和.pdb文件的方法
- TwoSAT算法模板
- [tool] google搜索的正确使用姿势(待补全)
- MegaCli命令使用详解
- Tomcat 在 Linux 上的安装和配置
- PHP的UTF-8中文转拼音处理类
- C++问题汇总
- ArcEngine 创建空间参考设置默认域
- jquery 滚动条位置的
- CentOS6.x 图形界面(gnome)安装
- codeforces水题100道 第十六题 Codeforces Round #164 (Div. 2) A. Games (brute force)
- 搭建基于HTTP协议内网yum仓库
- Hive学习之Locking
热门文章
- 精通CSS:高级Web标准解决方案(第二版) 初读笔记
- CTF—WEB—sql注入之宽字节注入
- python学习之面向对象(四)
- 小型自动化运维工具pssh和传输工具rsync
- 快速质因数分解及素性测试&;ABC142D
- 【神经网络与深度学习】caffe静态链接库“Unknown layer type: Convolution (known types: )”和“ 磁盘空间不足”问题的解决办法
- 【VS开发】ActiveX开发注意事项
- 【VS开发】【智能语音处理】特定人语音识别算法—DTW算法
- 简述Vue中使用Vuex
- 【洛谷p1058】立体图(已完结)