我写了以下代码:
<template v-slot="scope">
<div :class="getFuncationBarClass(scope)" :style="'{ --progress: `${getFunctionPercentage(scope)}` }'">{{getFuncationTotals(scope)}}</div>
</template>
出于某种原因,getFuncationBarClass
和getFuncationTotals
被调用,但getFunctionPercentage
没有被调用。我尝试了其他一些:style
变体,但它们都没有奏效。如何从样式绑定调用该方法?
在 Vue 中,你可以直接传递样式对象。您可以尝试:
<div :class="getFuncationBarClass(scope)" :style="{ '--progress': getFunctionPercentage(scope) }">{{getFuncationTotals(scope)}}</div>