当前位置:网站首页>Bind class style and bind style style
Bind class style and bind style style
2022-07-25 23:12:00 【Dignified 304】
css Code
<style>
* {
margin: 0;
padding: 0;
}
.basic {
width: 100px;
height: 100px;
border: 1px solid #000;
margin: 20px;
}
.red {
background-color: red;
}
.blue {
background-color: blue;
}
.yellow {
background-color: yellow;
}
.radius {
border-radius: 10px;
}
.widthboreder {
border: 10px solid #000;
}
</style>
html Code
binding class The pattern is v-bind:class="xxx" Shorthand for (:class="xxx") xxx yes data Attributes in can be arrays or objects
<body>
<div class="box">
<!-- String writing Applicable to style class name uncertainty , Need to dynamically specify -->
<div class="basic" :class="myColor" @click="changeColor">{
{name}}</div>
<!-- Array writing Applicable to the indeterminate number of styles to be bound , The class name is also uncertain -->
<div class="basic" :class="colorArr">{
{name}}</div>
<!-- Array writing Applicable to the determination of the number of styles to be bound , The class name is also determined But dynamic decision -->
<div class="basic" :class="colorObj">{
{name}}</div>
<!-- inline -->
<div class="basic" :style="styleObj1">{
{name}} object </div>
<div class="basic" :style="[styleOb1,styleObj2]">{
{name}}style Array </div>
</div>
</body>
js Code
<script>
// Cancel a developer prompt
Vue.config.productionTip = false;
// Create examples
new Vue({
el: '.box',
data: {
name: ' Lau Andy ',
myColor: 'red',
colorArr: ['blue', 'radius'],
colorObj: {
red: false,
blue: false,
yellow: true,
radius: true
},
styleObj1: {
// Property name must be css The name used in
fontSize: '30px',
},
styleObj2: {
backgroundColor: 'orange',
}
},
methods: {
changeColor() {
const arr = ['red', 'blue', 'yellow'];
this.myColor = 'blue',
console.log(this.myColor);
}
}
})
</script>边栏推荐
- 7-1 understand everything
- Sichuan cuisine menu (I)
- [PTA] 7-19 check face value (15 points)
- Wamp MySQL empty password
- WordPress function encyclopedia, you can do the theme after learning it
- [tensorflow] about seed
- Servlet overview
- Call Gaode map -- address is converted into longitude and latitude
- Anaconda installation tutorial environment variables (how to configure environment variables)
- ZCMU--5015: 完成任务
猜你喜欢

连续三年成为云AI服务领导者,亚马逊云科技做对了什么?

What has Amazon cloud technology done right to become the leader of cloud AI services for three consecutive years?

Memory paging and tuning, kernel and user space

Very simple vsplayaudio online music player plug-in

单模型常识推理首超人类!HFL登顶OpenBookQA挑战赛

Week 2: convolutional neural network

Apple CMS V10 template /mxone Pro adaptive film and television website template

Analysis of direction finding error of multi baseline interferometer system

【论文笔记】A Meta-Reinforcement Learning Algorithm for Causal Discovery

Mongodb的特点、与MySQL的差别、以及应用场景
随机推荐
Thinkphp6 temporarily close the layout
QT add mouse event to control
码蹄集 精准弹幕
5 ROS仿真建模(3- rviz+gazebo+控制仿真机器人)
Details of notification (status bar notification)
[literature reading] - HRL -[hrl with universal policies for multi step robotic control]
Understanding English (speech understanding)
Summary of common methods of string:
Ma Tiji Wanmin hall Chef
Secure code warrior learning record (III)
File contains vulnerability
CTS测试方法「建议收藏」
类和对象(2)(6个默认成员函数)
关于优先队列
uvm_ HDL -- implementation of DPI in UVM (4)
Enabling partners, how can Amazon cloud technology "get on the horse and get a ride"?
Network Security Learning (11) scanning and blasting
Network Security Learning notes-1 file upload
赋能合作伙伴,亚马逊云科技如何落地“扶上马,送一程”?
7-1 understand everything