我想动态控制Vuetify 走马灯组件中的
(<)
和(>)
箭头的可见性。
例如,使最后一个项目上的最后一个右箭头消失,或者在carousel-item
内容内部使用内部按钮或其他互动方式动态替换这些按钮。(我知道continuous
属性可以处理简单的结束场景)。
next-icon
和prev-icon
属性的文档是bool
或string
类型,其默认值为$next
。
Name next-icon Type boolean | string Default $next Description Icon used for the "next" button if show-arrows is true
我可以通过将其设置为false
来使图标按钮消失,但是true
不能使其重新出现。
我猜测字符串值是图标名称(例如md-arrow-right
?),但文档没有说明默认值是什么,而且那样也不起作用。我猜想“off”将属性设置为false
,“on”将其恢复为图标名称。
我还不理解$next
的含义,而这在页面上没有解释。如果您将其用作值,则会出错。其他所有内容似乎都计算为false。
我猜它应该是这样的:
<template>
<v-carousel v-model="stepNo" :show-arrows="show.arrows" :next-icon="show.nextArrow" height="auto" light>
<!-- ... -->
</template>
<script>
export default {
data: () => {
return {
stepNo: 0,
show: {
arrows: true,
nextArrow: "md-arrow-right",
},
}
},
watch: {
stepNo: function(newStep, oldStep) {
// some logic here, for example
this.nextArrow = (newStep === 4) ? "md-arrow-right" : false;
},
},
//...
}
</script>
更新
我的一个错误是将md-arrow-right
写成了mdi-arrow-right
(缺少字母),或者实际上应该是mdi-chevron-right
,正如tony19所指出的那样。所以现在我可以将它设置为文字图标。
但是将其设置为$next
或$prev
仍然不起作用-它要么显示为空,要么显示一个空圆圈,要么显示一个$符号,而这实际上是单词$next
。而且这似乎“破坏”了绑定,直到重新加载页面后将其设置为文本图标才能成功。
<i aria-hidden="true" class="v-icon notranslate material-icons theme--light" style="font-size: 36px;">$next</i>
continuous
设置为false
? - Liang-Shih Lin