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 ...
随机推荐
- linux中python3安装和使用
python安装 下载python安装包和依赖环境 #自由选择python3源码包的版本https://www.python.org/ftp/python/https://www.python.org ...
- XVII Open Cup named after E.V. Pankratiev. GP of Tatarstan
A. Arithmetic Derivative 形如$p^p(p是质数)$的数的比值为$1$,用$k$个这种数相乘得到的数的比值为$k$,爆搜即可. #include<cstdio> # ...
- Grodno 2015 (Urozero May 2015 Day 5)
A. Palindromes 留坑. B. Modules 将$a$排序,那么最优解中$a_n$一定放在前后一个,且前面$n-1$个每次要么放最小的,要么放最大的,区间DP即可. #include&l ...
- MySql数据and高级查询
1.CREATE TABLE grade(stuID INT AUTO_INCREMENT PRIMARY KEY NOT NULL,stuName VARCHAR(32),stuAge INT ) ...
- vue学习:安装及创建项目
1.先安装npm 参考链接:https://www.cnblogs.com/Hao-Killer/p/7235398.html 查看npm版本:在终端输入:npm -v 2.在安装vue # 安装vu ...
- React 简介及其基本使用
相关概念: 插件: 别人写好的第三方库 xxx 插件: jQuery 插件 / react 插件 全家桶: 核心库 + 相关插件 构建项目: 对项目源码 进行 编译.合并.压缩......处理,生 ...
- requirejs的使用和快速理解
样例来自https://www.jianshu.com/p/b8a6824c8e07 requirejs有以下功能 声明不同js文件之间的依赖 可以按需.并行.延时载入js库 可以让我们的代码以模块化 ...
- [LeetCode] K-th Smallest Prime Fraction 第K小的质分数
A sorted list A contains 1, plus some number of primes. Then, for every p < q in the list, we co ...
- linux学习:sed与awk与tr用法整理
流编辑器:sed 语法:sed [-hnV][-e<script>][-f<script文件>][文本文件] 参数: -e<script>或--expression ...
- java知识库
完善自己的成长之路,建立一套属于自己的系统知识体系,温故而知新. --HBX 1.java特性 2.java程序设计环境 3.java基本的设计结构 4.类与对象 参考资料:<java核心技术( ...