|
|
@ -1,6 +1,6 @@ |
|
|
|
<template> |
|
|
|
<div class="vote-results"> |
|
|
|
<div v-for="opt in options" :key="opt.id" class="progressContainer"> |
|
|
|
<div v-for="(opt,idx) in options" :key="opt.id" class="progressContainer"> |
|
|
|
<!-- 居中显示的状态 --> |
|
|
|
<el-progress |
|
|
|
v-if="voteStatus" |
|
|
@ -11,7 +11,7 @@ |
|
|
|
:text-inside="true" |
|
|
|
:color="colors[opt.id]" |
|
|
|
style="width: 300px;" |
|
|
|
@click="clickBtn(opt.id)" |
|
|
|
@click="clickBtn(opt.id,idx)" |
|
|
|
/> |
|
|
|
<!-- 显示 count 于灰条最右侧的状态 --> |
|
|
|
<div v-else class="progressWrapper"> |
|
|
@ -40,9 +40,9 @@ const totalStatus = () => { |
|
|
|
} |
|
|
|
|
|
|
|
const options = ref([ |
|
|
|
{ id: 1, content: '选择1', count: 20 }, |
|
|
|
{ id: 2, content: '选择2', count: 30 }, |
|
|
|
{ id: 3, content: '选择3', count: 40 }, |
|
|
|
{ id: 1, content: '选择1', count: 20 ,status:0}, |
|
|
|
{ id: 2, content: '选择2', count: 30 ,status:0}, |
|
|
|
{ id: 3, content: '选择3', count: 40 ,status:0}, |
|
|
|
]) |
|
|
|
|
|
|
|
const colors = ref({}) |
|
|
@ -61,8 +61,16 @@ function genUniqueColors() { |
|
|
|
} |
|
|
|
genUniqueColors() |
|
|
|
|
|
|
|
const clickBtn = idx => { |
|
|
|
console.log('点击了:', idx) |
|
|
|
const clickBtn = (id, index) => { |
|
|
|
console.log('点击了 id:', id, '索引:', index) |
|
|
|
let currentStatus = options.value[index].status |
|
|
|
if(!currentStatus){ |
|
|
|
options.value[index].content +=" √" |
|
|
|
}else{ |
|
|
|
options.value[index].content = options.value[index].content.replace(/ √$/, '') |
|
|
|
} |
|
|
|
options.value[index].status =!currentStatus |
|
|
|
|
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|