猿问

如何使用 Vue 从样式绑定调用方法?

我写了以下代码:


<template v-slot="scope">

    <div :class="getFuncationBarClass(scope)" :style="'{ --progress: `${getFunctionPercentage(scope)}` }'">{{getFuncationTotals(scope)}}</div>

</template>

由于某种原因getFuncationBarClass,getFuncationTotals被调用但getFunctionPercentage未被调用。我尝试了其他一些变体,:style但都没有用。如何从样式绑定中调用方法?


慕工程0101907
浏览 117回答 1
1回答

蛊毒传说

在 Vue 中你可以直接传递样式对象。你可以试试:<div&nbsp;:class="getFuncationBarClass(scope)"&nbsp;:style="{&nbsp;'--progress':&nbsp;getFunctionPercentage(scope)&nbsp;}">{{getFuncationTotals(scope)}}</div>
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答