当前位置:网站首页>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>边栏推荐
- 驱动板网线直连电脑共享网络配置
- 推荐系统——An Embedding Learning Framework for Numerical Features in CTR Prediction
- Thinkphp6 temporarily close the layout
- 码蹄集 万民堂大厨
- Recommend short videos every week: more and more smart devices need collaboration, posing a greater challenge to the development of the Internet of things?
- Check code generation
- Flight control implementation of four rotor aircraft "suggestions collection"
- How does Navicat modify the language (Chinese or English)?
- [literature reading] - HRL -[hrl with universal policies for multi step robotic control]
- 新手哪个券商开户最好 开户最安全
猜你喜欢

Single model common sense reasoning first surpasses human beings! HFL summit openbookqa challenge

Tips for using (1)

Network Security Learning (11) scanning and blasting

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

How to obtain the cash flow data of advertising services to help analyze the advertising effect?

How does PHP remove an element from an array based on the key value

Unity uses macros

serialization and deserialization

多模态——Deep Multi-Modal Sets

wordpress去掉网站发布时间
随机推荐
Apple CMS V10 template /mxone Pro adaptive film and television website template
serialization and deserialization
The small icon of notification setting shows a small square
Simulink学习笔记(三)——Simulink自动代码生成(二)「建议收藏」
赋能合作伙伴,亚马逊云科技如何落地“扶上马,送一程”?
Recommend short videos every week: more and more smart devices need collaboration, posing a greater challenge to the development of the Internet of things?
AI chief architect 12 AICA industrial landing analysis under the industrial production process optimization scenario
Zero crossing position search of discrete data (array)
[paper notes] robot dynamic tracking and grasping method based on online prediction and planning
Shanghai Second Polytechnic University - Health Daily autocheck
Tencent map API request source is not authorized, this request source domain name
内存分页与调优,内核与用户空间
ZCMU--5015: 完成任务
技术美术百人计划学习笔记(2)--向量
Flight control implementation of four rotor aircraft "suggestions collection"
Network Security Learning (16)
Network Security Learning (XII) OSI and TCP
Yii2 behavior usage and its calling method
The fifth article in the series of radar Fundamentals: the function of radar modulation style
Take away applet with main version of traffic / repair to add main access function of traffic