zoukankan      html  css  js  c++  java
  • 知识点8: 进度条制作,进度条宽度随数据变动

    情况一:

    • 效果图:

    • html(动态设置样式style为item.style)
                
    <div class="content_item" v-for="item in datasets" :key="item.index">
        <div class="progress_blue">
             <div class="progress_item" :style="item.style"></div>
         </div>
    </div>
    • js:(loadData()里,加载相关数据,赋值给width)
    mounted: {
         this.loadData();
    }
    methods: {
          loadData() {
                this.$http.post('indi/data', {
            'indiDsService': 1,
            'indiId': '10052',
            'indiType': 10,
            'parameter': {}
          }).then((res) => {
            if (res.data.data && res.data.data.length > 0) {
              res.data.data.forEach((ele, index) => {
                // console.log(res.data.data[index].KPI_NAME);
                this.datasets[index].country = res.data.data[index].KPI_NAME;
                this.datasets[index].nums = res.data.data[index].KPI_VALUE;
          //宽度随数据变动 this.datasets[index].style.width = `${res.data.data[index].KPI_VALUE}‰`; }); } }).catch((error) => { console.error(`10052 indicator has error`, error); }); } }

     情况二:

     效果图:(进度条根据旁边的数据联动)

     

     关键html:

     (动态设置样式style。其中num1需要在data中赋值,值是右侧的22)

    致力于前端技术学习与分享,会及时更新博客。
  • 相关阅读:
    bzoj1568: [JSOI2008]Blue Mary开公司
    bzoj3301: [USACO2011 Feb] Cow Line
    bzoj4745: [Usaco2016 Dec]Cow Checklist
    bzoj4746: [Usaco2016 Dec]Lasers and Mirrors
    bzoj2982: combination
    bzoj1822: [JSOI2010]Frozen Nova 冷冻波
    bzoj1027: [JSOI2007]合金
    bzoj 2004
    bzoj 3110&&codevs 1616
    bzoj 2134
  • 原文地址:https://www.cnblogs.com/caoxueying2018/p/9884534.html
Copyright © 2011-2022 走看看