首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ant Design Vue:当只有一个div内容时,旋转木马箭头消失

Ant Design Vue:当只有一个div内容时,旋转木马箭头消失
EN

Stack Overflow用户
提问于 2020-08-30 20:01:01
回答 1查看 571关注 0票数 5

我正在使用Ant Design Vue的Carousel在Instagram Story Clone项目中显示一些后端生成的数据。

问题是,当carousel中只有一个内容时,箭头和点就消失了。

转盘文档:https://antdv.com/components/carousel

代码沙盒:https://codesandbox.io/s/brave-blackwell-e6d5c?file=/src/App.vue

箭头显示:

代码语言:javascript
复制
<a-carousel arrows>

    <!-- Left Arrow -->
    <div
      slot="prevArrow"
      slot-scope="props"
      class="custom-slick-arrow"
      style="left: 10px;zIndex: 1"
    >
      <a-icon type="left-circle" />
    </div>

    <!-- Right Arrow -->
    <div
      slot="nextArrow" 
      slot-scope="props"
      class="custom-slick-arrow" 
      style="right: 10px"
    >
      <a-icon type="right-circle" />
    </div>

    <div><h3> Content 1 </h3></div>
    <div><h3> Content 2 </h3></div>
  </a-carousel>

箭头未显示:

代码语言:javascript
复制
<a-carousel arrows>

    <!-- Left Arrow -->
    <div
      slot="prevArrow"
      slot-scope="props"
      class="custom-slick-arrow"
      style="left: 10px;zIndex: 1"
    >
      <a-icon type="left-circle" />
    </div>

    <!-- Right Arrow -->
    <div
      slot="nextArrow" 
      slot-scope="props"
      class="custom-slick-arrow" 
      style="right: 10px"
    >
      <a-icon type="right-circle" />
    </div>

    <div><h3> Just content 1 </h3></div>
 </a-carousel>

当只有一个内容时,我如何确保箭头继续显示?

EN

回答 1

Stack Overflow用户

发布于 2020-09-05 20:00:33

如果你只有一张幻灯片,就不需要显示箭头,因为这不利于用户体验,但我会简单地建议添加一张幻灯片来指示幻灯片的结束:

代码语言:javascript
复制
  <a-carousel arrows>
    <!-- Left Arrow -->
    <div
      slot="prevArrow"
      slot-scope="props"
      class="custom-slick-arrow"
      style="left: 10px;zIndex: 1"
    >
      <a-icon type="left-circle"/>
    </div>

    <!-- Right Arrow -->
    <div slot="nextArrow" slot-scope="props" class="custom-slick-arrow" style="right: 10px">
      <a-icon type="right-circle"/>
    </div>

  
    <div>
      <h3>1</h3>
    </div>
    <div>
      <h3>End :)</h3>
       <h4> Don't forget to follow us</h4>
    </div>
   
  </a-carousel>
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63657202

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档