/*
* @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的东西的更多相关文章

  1. Vue.js 源码分析(十三) 基础篇 组件 props属性详解

    父组件通过props属性向子组件传递数据,定义组件的时候可以定义一个props属性,值可以是一个字符串数组或一个对象. 例如: <!DOCTYPE html> <html lang= ...

  2. vue组件之属性Props

    组件的属性和事件 父子组件之间的通信 父子组件之间的通信就是 props down,events up,父组件通过 属性props向下传递数据给子组件,子组件通过 事件events 给父组件发送消息. ...

  3. vue & modal props & form data update bug

    vue & modal props & form data update bug OK <div> <BindModal :dialogBindVisible=&qu ...

  4. Vue2.x源码学习笔记-Vue实例的属性和方法整理

    还是先从浏览器直观的感受下实例属性和方法. 实例属性: 对应解释如下: vm._uid // 自增的id vm._isVue // 标示是vue对象,避免被observe vm._renderProx ...

  5. Vue的Key属性,v-for和v-if,v-if/v-show,v-pre不渲染,v-once只渲染一次

    key属性为什么要加 key -- api 解释 key的特殊属性主要用在vue的虚拟dom算法,如果不适用key,vue会使用一种最大限度减少动态元素并且尽可能的尝试修复/再利用相同类型元素的算法. ...

  6. [转]Vue中用props给data赋初始值遇到的问题解决

    原文地址:https://segmentfault.com/a/1190000017149162 2018-11-28更:文章发布后因为存在理解错误,经@Kim09AI同学提醒后做了调整,在此深表感谢 ...

  7. Vue中用props给data赋初始值遇到的问题解决

    Vue中用props给data赋初始值遇到的问题解决 更新时间:2018年11月27日 10:09:14   作者:yuyongyu    我要评论   这篇文章主要介绍了Vue中用props给dat ...

  8. Vue2.0 【第二季】第7节 Component 组件 props 属性设置

    目录 Vue2.0 [第二季]第7节 Component 组件 props 属性设置 第7节 Component 组件 props 属性设置 一.定义属性并获取属性值 二.属性中带' - '的处理方式 ...

  9. Vue computed props pass params

    Vue computed props pass params vue 计算属性传参数 // 计算 spreaderAlias spreaderAlias () { console.log('this. ...

随机推荐

  1. TextBox 设置数据源的自动补全输入字符串功能

    这个东西首先说明是不是自己原创,但是比较简单.所以讲起分享如下.主要是用到TextBox的自动补全属性,这个东西虽然自己以前经常用TextBox,但是补全从没接触过. 关键代码是在窗体载入时加载如下代 ...

  2. 「小程序JAVA实战」小程序我的个人信息页面开发(41)

    转自:https://idig8.com/2018/09/05/xiaochengxujavashizhanxiaochengxuwodegerenxinxiyemiankaifa40/ 已经完成了登 ...

  3. swagger报No operations defined in spec!

    突然发现项目的swagger报No operations defined in spec! SWAGGER_SCAN_BASE_PACKAGE 路径改变了! package com.redis.con ...

  4. quartz简介

  5. mysql主从错误180301

    Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ...

  6. pyinstaller 打包

    [root@mhc nsf]# pip install pyinstallerCollecting pyinstaller  Downloading PyInstaller-3.3.tar.gz (3 ...

  7. JavaScript中的一些小技巧

    js 数字操作:1.1 取整:取整有很多方法如: parseInt(a,10); Math.floor(a); a>>0; ~~a; a|0; 前面2种是经常用到的,后面3种算是比较偏的, ...

  8. Paradox

    克己博伦 当一个无法阻挡的力量,碰到了一个无法移动的物体?如果这个力量移动了物体,那么这个物体就不是无法移动的.如果这个力量没有移动物体,那么这个无法阻挡的力量就被挡了下来. 上帝能造出一个重到他自己 ...

  9. 电脑破解wifi密码(至少连过1次的才可以)

    电脑破解wifi密码(至少连过1次的才可以) 连过的wifi密码忘记了怎么办? 只要你电脑连过的都能破解. cmd输入以下内容查看电脑连接过的wifi名字. netsh wlan show profi ...

  10. 重定向和请求转发后面加“return;”语句

    请求转发  RequestDispatcher 重定向     Redirect 代码的执行: 无论是 request.getRequestDispatcher(path).forward(reque ...