vue中样式的典型操作(:class,:style)
<template>
<div class="home-wrapper">
<div class="home-top">this is from Home.vue</div>
<!--num>10,背景颜色红色,否则橙色-->
<div class="test" :class="num>10? bgColor1: bgColor2">this is a test,num is : {{num}}</div>
<button @click="changeNum">click to change num</button>
<div class="test2" :style="{fontSize: fontSize+ 'px'}">this is test2</div>
<button @click="changeTest2FontSize">click to change fontSize</button>
</div>
</template> <script>
export default {
name: 'Home',
data () {
return {
num: '',
bgColor1: 'bgColor1',
bgColor2: 'bgColor2',
fontSize: 10
}
},
methods: {
changeNum () {
this.num = Math.floor(Math.random() * 20)
console.log(this.num)
},
changeTest2FontSize () {
if (this.fontSize < 30) {
this.fontSize = 30
} else {
this.fontSize = 15
}
}
}
}
</script> <style lang="scss" scoped>
.home-wrapper{
width: 80%;
display: flex;
align-items: center;
flex-direction: column;
.home-top{
width: 300px;
height: 100px;
}
.bgColor1{
background-color: red;
}
.bgColor2{
background-color: orange;
}
.test{
width: 300px;
height: 200px;
}
} </style>
代码如上!
vue中样式的典型操作(:class,:style)的更多相关文章
- vue_music:排行榜rank中top-list.vue中样式的实现:class
排行榜的歌曲列表,根据排名渲染不同的样式,同时需要考虑分辨率的2x 3x图 不同的样式--:class 考虑分辨率的2x 3x图--需要在stylu中的mixin中bgImage根据屏幕分辨率选择图片 ...
- Vue中对data的操作
1. {{a}} var vm = new Vue({ el: '#app', data: { a: { a: 1, b: 2 } } }) vm.a.c = 'sadoisad' // 按理说是 ...
- 09.vue中样式-style
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 【转】vue中样式被覆盖的问题,vue中的style不生效
转载:http://www.cnblogs.com/shangjun6/p/11416054.html 在我们引入外部的样式时,发现自己无论如何都改不了外部的样式,自己的样式老被覆盖,究其原因还是我们 ...
- vue 中样式的绑定
1.class的对象绑定 //对应的css <style> .active { color: red; } </style> <!--html 对应的代码--> & ...
- vue中,class、内联style绑定、computed属性
1.绑定Class ①对象语法 <li :class="{ 'active': activeIdx==0 }" @click="fnClickTab(0)" ...
- 08.vue中样式-class
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- vue中关于dom的操作
mounted 个人理解为DOM结构准备就绪了,可以开始加载vue数据了, 挂载点,配合使用 mounted:function(){ this.$nextTick(function(){ //this ...
- vue学习(八) vue中样式 class 定义引用
//style<style> .red{ color:red; } .thin{//字体粗细 font-weight:200 } .italic{//字体倾斜 font-style:ita ...
随机推荐
- 如何在webpack中成功引用到图片?
打包图片时,你可曾遇到在产出目录文件夹找不到图片,即便找到了,但是页面说引用不到资源?页面上或者文件中引用的图片地址不对? 一.在webpack中引入图片需要url-loader //webpack配 ...
- 王燕 201771010126《面向对象程序设计(java)》第一周学习总结
王燕 201771010126<面向对象程序设计(java)>第一周学习总结 王燕 201771010126<面向对象程序设计(java)>第一周学习总结 第一部分:课程准备部 ...
- 【并查集缩点+tarjan无向图求桥】Where are you @牛客练习赛32 D
目录 [并查集缩点+tarjan无向图求桥]Where are you @牛客练习赛32 D PROBLEM SOLUTION CODE [并查集缩点+tarjan无向图求桥]Where are yo ...
- 顺序表的原理与python中的list类型
数据是如何在内存中存储的? 在32位的计算机上,1个字节有8位,内存寻址的最小单位就是字节.假设我们有一个int类型的值,它从0x10开始,一个int占据4个字节,则其结束于0x13. 那么数据类型有 ...
- [LeetCode] Binary Trees With Factors 带因子的二叉树
Given an array of unique integers, each integer is strictly greater than 1. We make a binary tree us ...
- ORACLE中通过SQL语句(alter table)来增加、删除、修改字段
1.添加字段: alter table 表名 add (字段 字段类型) [ default '输入默认值'] [null/not null] ; 2.添加备注: comment on ...
- 9、vuex快速上手
vue脚手架 npm install -g vue-cli usage: vue init example: vue init webpack myvue 安装vuex: npm i -S vuex ...
- 2019.3.22 JMeter基础操作
1.添加线程组:testplan—添加—线程(用户)Threads(Users) 线程属性值:线程数(虚拟用户数).Rump-up(准备时长:设置所有线程全部启动时间).循环次数(每个线程重复发送请求 ...
- 微信小程序页面带参数跳转
页面传递参数的方式 data-para js获取参数
- Codeforces 785D - Anton and School - 2 - [范德蒙德恒等式][快速幂+逆元]
题目链接:https://codeforces.com/problemset/problem/785/D 题解: 首先很好想的,如果我们预处理出每个 "(" 的左边还有 $x$ 个 ...