身体有九个基础指标,为了不重复写同样的代码,写了一个进度条组件:
创建一个组件叫progress
progress.json的代码
{
"component": true,
"usingComponents": {}
}
progress.wxml的代码
<!--pages/bodyScale/progress/progress.wxml-->
<view class="parent">
<view style="width:{
{totalWidth}}px; margin:0 auto;">
<view class="progress" style="padding-left:{
{half_width}}px; padding-right:{
{half_width}}px;">
<view wx:for="{
{num}}" wx:for-index="index" wx:for-item="numItem">
<view style="width:{
{width}}px;font-size: 12px;color: #6C6E6F;text-align: center;">{
{numItem}}</view>
</view>
</view>
<view class='progress_item'>
<view class="progress" style='padding-top:14rpx;'>
<view wx:for="{
{colors}}" wx:for-index="index" wx:for-item="color">
<view style="background:{
{color}}; height: 6rpx; width:{
{width}}px;margin-right:5rpx;" />
</view>
</view>