🐛 fix(App): 修复 getClassName 函数中的计算逻辑错误
This commit is contained in:
parent
a2acabc471
commit
03173f952b
11
src/App.vue
11
src/App.vue
|
@ -21,15 +21,16 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
const selectIndex = ref(-1)
|
const selectIndex = ref(-1)
|
||||||
const selectIndexWidth = ref(0)
|
const selectIndexWidth = ref(0)
|
||||||
|
|
||||||
|
const min = computed(() => selectIndex.value)
|
||||||
|
const max = computed(() => selectIndexWidth.value + selectIndex.value)
|
||||||
|
|
||||||
function getClassName(i) {
|
function getClassName(i) {
|
||||||
const min = selectIndex.value
|
if (Math.max(max.value, 30) === max.value && Math.min(i, min.value) === min.value) return 'warn'
|
||||||
const max = selectIndexWidth.value + selectIndex.value
|
if (Math.min(min.value, i) === min.value && Math.max(max.value, i) === max.value) return 'select'
|
||||||
if (Math.max(max, 30) === max && Math.min(i, min) === min) return 'warn'
|
|
||||||
if (Math.min(min, i) === min && Math.max(max, i) === max) return 'select'
|
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue