我尝试使用:
来增加值:data-value="Math.round(elecs[index].obtenus/elecs[index].maxsiege*100)
我的迭代:
:data-value="Math.round(result += elecs[index].obtenus/elecs[index].maxsiege*100)
谢谢!
更多:
<ul class="pie-wrapper" >
<li v-for="(elec, index) in elecs" :key="index" v-if="elecs[index].obtenus != 0" class="arc" :data-value="Math.round(elecs[index].obtenus/elecs[index].maxsiege*100)">
<b>{{ elecs[index].Sigle }} </b>
<span>{{elecs[index].obtenus}}/{{elecs[index].maxsiege}}</span>
</li>
</ul>
脚本:
export default {
async asyncData({ params }) {
... json
return {
...json
}
},
methods: {
toCurrencyString(number){
return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
}
}
}
答案 0 :(得分:0)
好吧,我找到了!感谢Max Sinev让我走上正确的路!
methods: {
toCurrencyString(number){
return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
},
tottest(elecs, index){
return result += Math.round(elecs[index].obtenus/elecs[index].maxsiege*100);
}
}
在我的模板中:
<ul class="pie-wrapper" >
<li v-for="(elec, index) in elecs" :key="index" v-if="elecs[index].obtenus != 0" class="arc" :data-value="tottest(elecs, index)">
</li>
</ul>