如何在微信小程序中实现如下效果?

就是类似于图中这种子元素溢出自动折叠,并且有一个可以展开的按钮。

阅读 1.7k
2 个回答
新手上路,请多包涵

浮动 弹性盒 自适应

<div :class="isAllHeight % 2 != 0 ? 'common-search-all-h' : 'search-wrapper'">
 
</div>
<div>
        <span
          @click="seachMore"
          v-if="isAllHeight % 2 == 0"
          class="have-more-info"
          ><i class="el-icon-arrow-down"></i></span
        >
        <span
          @click="seachMore"
          v-if="isAllHeight % 2 != 0"
          class="have-more-info"
          ><i class="el-icon-arrow-up"></i></span
        >
</div>
data() {
    return {
      isAllHeight: 0,
    }
}
methods:{
  seachMore() {
      this.isAllHeight++;
  },
}
<style>
  .search-wrapper {
    background: #fff;
    padding: 20px 0 0 20px;
    border-radius: 4px;
    height: 70px;
    overflow: hidden;
  }

  .common-search-all-h {
    background: #fff;
    padding: 20px 0 0 20px;
    border-radius: 4px;
    height: 100%;
  }
</style>
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题