
Collapse, CollapseItem组件van-collapse-item折叠面板进行判断,如果有内容显示箭头可点击,否则箭头不显示!
具体实现代码如下:
<template>
<van-collapse v-model="activeNames">
<van-collapse-item
v-for="(item, index) in items"
:key="index"
:title="item.title"
:name="`item-${index}`"
:clickable="item.hasContent"
>
<div v-if="item.hasContent">
<!-- 内容区域 -->
{{ item.content }}
</div>
<!-- 使用 slot 自定义标题,包括箭头 -->
<template #title>
<div class="custom-title">
{{ item.title }}
<van-icon
v-if="item.hasContent"
class="arrow"
name="arrow-right"
/>
</div>
</template>
</van-collapse-item>
</van-collapse>
</template>
<script>
export default {
data() {
return {
activeNames: [], // 控制折叠面板的展开和收起
items: [
{ title: '标题1', content: '内容1', hasContent: true },
{ title: '标题2', content: '', hasContent: false }, // 没有内容
// ... 其他条目
],
};
},
};
</script>
<style scoped>
.custom-title {
display: flex;
justify-content: space-between;
align-items: center;
}
.arrow {
// 箭头的样式
}
</style>
van-picker选择器没有取消/确认按钮和标题解决方法!
上面是“van-collapse-item折叠面板判断,有内容显示箭头可点击”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_14465.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

vuejs如何动态修改浏览器title
尾崎八项是指哪八项,有人挑战成功吗?
适当的图片优化如何帮助网站seo排名?
百度echarts X轴把小数点去掉