您的位置:首页 > 游戏 > 手游 > 网络销售入门基本知识_网页怎么发布_西安外包网络推广_seo短视频入口引流

网络销售入门基本知识_网页怎么发布_西安外包网络推广_seo短视频入口引流

2025/3/12 11:59:31 来源:https://blog.csdn.net/qq_53911056/article/details/144405913  浏览:    关键词:网络销售入门基本知识_网页怎么发布_西安外包网络推广_seo短视频入口引流
网络销售入门基本知识_网页怎么发布_西安外包网络推广_seo短视频入口引流

一、Progress组件

二、各部分代码

 1.html代码

<div><div class="showprogress" v-for="item in regions" :key="item.name"><span>{{ item.name }}</span><el-progress :percentage="percentage(item.count, totalCount)" :format="formatCount(item.count)" :color="customColorMethod"></el-progress></div>
</div>

使用v-for指令遍历regions数组,为每个区域创建一个进度条显示。

使用<el-progress>组件(Element UI库中的进度条组件)来显示进度。

:percentage:计算并绑定每个进度条的百分比。

:format:自定义进度条上显示的文本。

:color="customColors":绑定进度条的颜色。


2.部分CSS代码

.showprogress{display: flex;justify-content: space-around;align-items: center;span {width: 50px;font-size: 12px;color: #8CBAEE;}/deep/.el-progress__text {font-size: 12px !important;color: #8CBAEE;}
}

regions数组:定义了名称及其对应的count值,可动态获取数据。

totalCount:定义了用于计算百分比的总数。

percentage方法:接受两个参数(counttotal),计算并返回百分比。

formatCount方法:常见的做法是直接显示百分比或者格式化后的百分比字符串。

customColorMethod方法:根据进度百分比返回不同的颜色。

3.js代码

  data() {return {regions: [{ name: "大足区", count: 80 },{ name: "秀山县", count: 100 },{ name: "涪陵区", count: 160 },{ name: "万州区", count: 40 },{ name: "忠县", count: 200 }],totalCount: 200};},methods: {percentage(count, total) {return (count / total) * 100;},formatCount(count) {return percentage => {return `${count}`; // 直接返回条数};},customColorMethod(percentage) {if (percentage < 20) {return "#8C39A1";} else if (percentage < 40) {return "#04FCFC";} else if (percentage < 60) {return "#7C3DFD";}else if (percentage < 80) {return "#01A4E7"}else {return "#6f7ad3";}},},}

以上是一个简单的进度条展示样式,实现其他样式需细节上修改一些。

 若文章对你有帮助,点赞、收藏加关注吧!

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com