<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<title>Document</title>
</head>
<style>
*{
margin:0;
padding:0;
}
html,body{
width:100%;
height:100%;
}
.bigbox{
padding-bottom:0.3rem;
position: relative;
}
.echarts{
width:5.27rem;
height:3.2rem;
margin:0 auto;
background-image: url(img/echarts.png);
background-size: 100% 100%;
display: flex;
justify-content: space-around;
position: relative;
padding:0.05rem 0.5rem;
box-sizing: border-box;
}
.echarts>span{
position: absolute;
left:-0.3rem;
font-size: 0.2rem;
color:#666;
font-weight: 600;
}
.echarts>span:first-child{
top:0.2rem
}
.echarts>span:nth-child(2){
top:0.42rem
}
.echarts>.bar{
width:1rem;
height:100%;
position: relative;
/* bottom:0; */
}
.echarts>.bar>div{
position: absolute;
bottom:0;
/* height:2rem; */
width:100%;
padding-top:0.3rem;
box-sizing: border-box;
text-align: center;
/* background-color: salmon; */
border-radius: 0.2rem 0.2rem 0px 0px;
font-size: 0.2rem;
color:#fff;
font-weight: 600;
}
.echarts>.bar>div>span{
position: absolute;
bottom:-0.3rem;
left:50%;
transform: translateX(-50%);
font-size: 0.2rem;
color:#666;
display: block;
width:100%
}
.bar1>div{
background-color: #4281FF;
}
.bar2>div{
background-color: #73A1FF;
}
</style>
<body>
<div id="app">
<div class="bigbox">
<div class="echarts">
<span>数</span>
<span>值</span>
<div class="bar bar1" >
<div :style="my_bar">
{{myS}}
<span>您的得分</span>
</div>
</div>
<div class="bar bar2">
<div :style="lv_bar">
125
<span>平均得分</span>
</div>
</div>
</div>
</div>
</div>
</body>
<script>
(function(doc, win) {
var docEl = doc.documentElement,
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
recalc = function() {
var clientWidth = docEl.clientWidth;
if (!clientWidth) return;
if (clientWidth >= 750) {
docEl.style.fontSize = '100px';
} else {
docEl.style.fontSize = 100 * (clientWidth / 750) + 'px';
}
};
if (!doc.addEventListener) return;
win.addEventListener(resizeEvt, recalc, false);
doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);
var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!',
my_bar:'',
lv_bar:'',
maxS:174,//最高分数
lvS:125,//平均分数
myS:0//我的分数
},
methods:{
setheight(mys){
this.myS = mys
this.my_bar = 'height:'+ parseInt(mys/this.maxS*100)+'%'
this.lv_bar = 'height:'+parseInt(125/this.maxS*100)+'%'
console.log(this.my_bar)
}
},
mounted() {
this.setheight(80)
},
})
</script>
</html>