/*
* @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. libaco: 一个极速的轻量级 C 非对称协程库 🚀 (10 ns/ctxsw + 一千万协程并发仅耗内存 2.8GB + Github Trending)

    0 Name 简介 libaco - 一个极速的.轻量级.C语言非对称协程库. 这个项目的代号是Arkenstone 

  2. 利用Console来学习、调试JavaScript

    一  什么是 Console Console 是用于显示 JS和 DOM 对象信息的单独窗口.并且向 JS 中注入1个 console 对象,使用该对象 可以输出信息到 Console 窗口中. 二  ...

  3. kali linux:wireshark不能被root用户启用的解决方案

    启动wireshark后,报错: 该界面提示在init.lua文件中使用dofile函数禁用了使用超级用户运行wireshark.这是因为wireshark工具是使用Lua语言编写的,并且在kali ...

  4. cf499A-Watching a movie

    http://codeforces.com/problemset/problem/499/A A. Watching a movie   You have decided to watch the b ...

  5. HTTP协议简析(二)

    HTTP响应也包含四部分内容: 响应行: 协议版本:HTTP/1.1 状态码:200 状态描述:对状态码的说明 响应头:用来规范数据,常用的有: server:服务器信息 date:响应的时间 las ...

  6. 7-set用法详解

    C++中set用法详解 转载 http://blog.csdn.net/yas12345678/article/details/52601454 C++ / set 更详细见:http://www.c ...

  7. WebAPI的路由规则

    1.自定义路由 public static class WebApiConfig { public static void Register(HttpConfiguration config) { / ...

  8. code1154 能量项链

    d[l][i]表示:从第i个珠子开始,连续l个珠子合并后释放的最大能量 状态转移方程d[l][i] = d[j][i] + d[l-j][i+j] + w[i]*w[i+j]*w[i+l],j从1到l ...

  9. 快速求出n!的质因数的个数

    一般做组合数的题目都要进行质因数的分解,我们一般是for循环对每个数进行质因数分解,大多数情况都不会超时,但极少数的情况下,题目会不允许这样的做法,所以我们需要学会一种更快的方法来求质因数. 我们一般 ...

  10. [Groovy] Groovy API

    http://www.soapui.org/about-soapui/soapui-faq.html#1-SoapUI--General-Questions 3.1.1. What is Groovy ...