当前位置:网站首页>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>边栏推荐
- serialization and deserialization
- Shanghai Second Polytechnic University - Health Daily autocheck
- Details of notification (status bar notification)
- [PTA] 7-19 check face value (15 points)
- 技术美术百人计划学习笔记(1)--基础渲染管线
- 四旋翼飞行器的飞控实现「建议收藏」
- How to set pseudo static for WordPress fixed links
- What are the differences between FileInputStream and bufferedinputstream?
- PCL basic operation Encyclopedia
- Design of regular expressions
猜你喜欢

栈与Stack类

The fifth article in the series of radar Fundamentals: the function of radar modulation style

QT operation to solve large amount of duplicate data

Week 2: convolutional neural network

如何获取广告服务流量变现数据,助力广告效果分析?

Source code of wechat applet for discerning flowers and plants / source code of wechat applet for discerning plants

Discuz magazine / news report template (jeavi_line) utf8 GBK / DZ template download

Secure code warrior learning record (III)

Secure code warrior learning record (IV)

Network Security Learning notes-1 file upload
随机推荐
The small icon of notification setting shows a small square
serialization and deserialization
Firewall command simple operation
HJ7 取近似值
QT operation to solve large amount of duplicate data
5 ROS simulation modeling (3-rviz+gazebo+ control simulation robot)
How to obtain the cash flow data of advertising services to help analyze the advertising effect?
[PTA] 7-24 minimum fraction (15 points)
第二周学习:卷积神经网络
Zero crossing position search of discrete data (array)
Single model common sense reasoning first surpasses human beings! HFL summit openbookqa challenge
Design of Butterworth filter and drawing of amplitude frequency characteristic curve
码蹄集 精准弹幕
General paging function
[tensorflow] about seed
The difference between overloading and rewriting
QT add mouse event to control
Discuz magazine / news report template (jeavi_line) utf8 GBK / DZ template download
Experience of machine learning with Google Lab
The fifth article in the series of radar Fundamentals: the function of radar modulation style