CSS 生成等份扇形
<template v-for="item in 50"> <div :key="item" v-if="item > 1" :style="{background:drawSector(item)}" class="one"></div> </template> drawSector(num = 2){ let colors = ['#EEC900','#EEC591','#EEB4B4','#EEB422','#EEAEEE','#7D7D7D','#7D26CD','#7CFC00','#7CCD7C','#A1A1A1','#A0522D','#A020F0','#9FB6CD'] colors = [...colors,...colors,...colors,...colors,...colors,...colors,...colors,...colors] let perDeg = 360 / num let str = 'conic-gradient(' for(let i=0;i<num;i+=1){ str += `${colors[i]} ${i * perDeg}deg ${(i+1) * perDeg}deg,` } str = str.slice(0,-1) str += ')' return str },