vue的props 属性类似于bug的东西
/*
* @Author: shs
* @Date: 2019-04-19 17:48:39
* @Last Modified by: shs
* @Last Modified time: 2019-04-22 11:30:55
*/
<template>
<div class="p-r" style="overflow: hidden" :style="{width: widths, background: 'lightgray'}">
<div class="p-a" :style="{width: actwidths, background: '#4cf9ff'}"></div>
<span class="left"><span>{{dataf.cur}}</span>{{dataf.leftword}}</span><span class="right">{{dataf.rightword1}}<span>{{dataf.total}}</span>{{dataf.rightword2}}</span>
</div>
</template>
<script>
export default {
data () {
return {
actwidths: '0%'
}
},
props: {
dataf: {
type: Object,
default: {
total: 0,
cur: 0,
leftword: '台开机',
rightword1: '总',
rightword2: '台'
}
},
widths: {
type: String,
defalut: '100%'
},
settings: {
type: Object,
defalut: { }
}
},
methods: { },
watch: {
data: function(val, old) {
if (val.total !== 0 && val.cur !== 0) { //total
this.actwidths = ((val.cur/val.total) * 100).toFixed(1) +'%'
console.log(this.actwidths)
}
}
},
mounted () { //wait dom loading, operate data if (this.dataf.total !== 0&&this.dataf.cur !== 0) { //total
console.log(this.dataf)
this.actwidths = ((this.dataf.cur/this.dataf.total) * 100).toFixed(1) +'%'
console.log(this.actwidths)
}
}
}
</script> <style lang="scss" scoped>
$back-fill: #4cf9ff;
$height: 30px;
$font-color: white;
.p-r {
position: relative;
width: 100%;
height: $height;
}
.p-a {
display: inline-block;
position: absolute;
top: 0;
left: 0;
height: $height;
}
.p-a:after {
content: '';
display: inline-block;
position: absolute;
top: 0;
right: -10px;
border-top: 20px solid $back-fill;
border-left: 5px solid $back-fill;
border-right: 5px solid transparent;
border-bottom: 20px solid transparent;
}
.left {
display: inline-block;
position: absolute;
top:0;
left: 10px;
height: $height;
width: 50%;
line-height: $height;
color: $font-color;
}
.right {
display: inline-block;
position: absolute;
top: 0;
right: 10px;
height: $height;
width: 50%;
line-height: $height;
text-align: right;
color: $font-color;
}
</style>
vue的props 属性类似于bug的东西的更多相关文章
- Vue.js 源码分析(十三) 基础篇 组件 props属性详解
父组件通过props属性向子组件传递数据,定义组件的时候可以定义一个props属性,值可以是一个字符串数组或一个对象. 例如: <!DOCTYPE html> <html lang= ...
- vue组件之属性Props
组件的属性和事件 父子组件之间的通信 父子组件之间的通信就是 props down,events up,父组件通过 属性props向下传递数据给子组件,子组件通过 事件events 给父组件发送消息. ...
- vue & modal props & form data update bug
vue & modal props & form data update bug OK <div> <BindModal :dialogBindVisible=&qu ...
- Vue2.x源码学习笔记-Vue实例的属性和方法整理
还是先从浏览器直观的感受下实例属性和方法. 实例属性: 对应解释如下: vm._uid // 自增的id vm._isVue // 标示是vue对象,避免被observe vm._renderProx ...
- Vue的Key属性,v-for和v-if,v-if/v-show,v-pre不渲染,v-once只渲染一次
key属性为什么要加 key -- api 解释 key的特殊属性主要用在vue的虚拟dom算法,如果不适用key,vue会使用一种最大限度减少动态元素并且尽可能的尝试修复/再利用相同类型元素的算法. ...
- [转]Vue中用props给data赋初始值遇到的问题解决
原文地址:https://segmentfault.com/a/1190000017149162 2018-11-28更:文章发布后因为存在理解错误,经@Kim09AI同学提醒后做了调整,在此深表感谢 ...
- Vue中用props给data赋初始值遇到的问题解决
Vue中用props给data赋初始值遇到的问题解决 更新时间:2018年11月27日 10:09:14 作者:yuyongyu 我要评论 这篇文章主要介绍了Vue中用props给dat ...
- Vue2.0 【第二季】第7节 Component 组件 props 属性设置
目录 Vue2.0 [第二季]第7节 Component 组件 props 属性设置 第7节 Component 组件 props 属性设置 一.定义属性并获取属性值 二.属性中带' - '的处理方式 ...
- Vue computed props pass params
Vue computed props pass params vue 计算属性传参数 // 计算 spreaderAlias spreaderAlias () { console.log('this. ...
随机推荐
- python学习——练习题(11)
""" 题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少? 1 1 2 ...
- RHCE7 学习里程-4用户权限,简单进程管理
#创建用户 useradd abc 使用 vipw 命令查看 /etc/passwd 文件下 是否存在新用户 #G却换到最后一行 #创建账号的时候,默认也新建了一个组,组名跟用户名一样 groupad ...
- MySQL中函数CONCAT及GROUP_CONCAT函数的使用
一.CONCAT()函数 CONCAT()函数用于将多个字符串连接成一个字符串. 以数据表[user]作为实例: SELECT USER_NAME, SEX FROM USER WHERE USER ...
- 2018-2019第一学期Java助教心得
随着期末考试落下了帷幕,本学习也结束了回顾本学期的历程,对我影响最深的还是这学期很幸运的成为代老师的助教,这也是我第一次接触助教工作.刚开始的时候我心里也有很多的担心,怕自己胜任不了这份工作,但随着时 ...
- centos6 安装 docker
一.升级内核(带aufs模块) 1.yum安装带aufs模块的3.10内核(或到这里下载kernel手动安装:http://down.51cto.com/data/1903250) cd /etc/y ...
- 待解决:2bootstrap-cerulean.css Failed to load resource: the server responded with a status of 404 ()
2bootstrap-cerulean.css Failed to load resource: the server responded with a status of 404 ()
- centos6.5 svn服务端搭建
一.前言 Subversion是一个免费的开源的版本管理系统,它是作为CVS(Concurrent Versions System)的取代品出现的.本文简单介绍了Subversion在centos上的 ...
- SpringBoot的配置属性文件*.properties值如何映射到类中使用
想要在JAVA Bean中读取配置文件中的内容有两种方式,可以进行获取到 第一种方式: 1.在默认的配置文件application.properties 中进行设置 Key-Value键值对 com. ...
- mysql 数学操作函数
-- 绝对值,圆周率 SELECT ABS(-1),3*PI() -- 平方根,求余 SELECT SQRT(9),MOD(9,5) -- 获取整数的函数 SELECT CEIL(12.145),CE ...
- [GO]结构体的比较和赋值
package main import "fmt" func main() { type student struct { id int name string sex byte ...