refactor: 使用repeating-conic-gradient简化代码
This commit is contained in:
parent
c1f6e467b6
commit
ad7b990413
@ -85,13 +85,10 @@ const totalRunAngle = computed(() => {
|
|||||||
|
|
||||||
// 计算绘制转盘背景
|
// 计算绘制转盘背景
|
||||||
const bgColor = (() => {
|
const bgColor = (() => {
|
||||||
const _len = prizeList.length
|
const [c1, c2] = ['#5352b3', '#363589']
|
||||||
const colorList = ['#5352b3', '#363589']
|
// repeating-conic-gradient(red 0 15deg, blue 15deg 30deg);
|
||||||
let colorVal = ''
|
return `background: repeating-conic-gradient(${c1} 0 ${rotateAngle.value}deg,
|
||||||
for (let i = 0; i < _len; i++) {
|
${c2} ${rotateAngle.value}deg ${2 * rotateAngle.value}deg);`
|
||||||
colorVal += `${colorList[i % 2]} ${rotateAngle.value * i}deg ${rotateAngle.value * (i + 1)}deg,`
|
|
||||||
}
|
|
||||||
return `background: conic-gradient(${colorVal.slice(0, -1)});`
|
|
||||||
})()
|
})()
|
||||||
|
|
||||||
const styleObj = ref(bgColor)
|
const styleObj = ref(bgColor)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user