首页 > 其他分享 >【快应用】list组件属性的运用指导

【快应用】list组件属性的运用指导

时间:2023-08-07 11:44:32浏览次数:30  
标签:name column list height item 组件 属性

​ 【关键词】

list、瀑布流、刷新、页面布局

 

【问题背景】

1、  页面部分内容需要瀑布流格式展示,在使用lsit列表组件设置columns进行多列渲染时,此时在里面加入刷新动画时,动画只占了list组件的一列,并没有完全占据一行宽度,这种情形我们该如何处理?

如下图所示

cke_270.png

2、当页面是可滑动时,嵌套了一个list组件,滑动list组件时,页面的内容不会跟着list组件滑动,只有当list组件滑动到顶/底,不能滑动时才能滑动页面的内容,这个我们该如何避免?

 

【解决方案】

1、是因为在设置list列数后,list-item是会跟设置的列数平均分配,所以会出现动画组件占了一部分的问题,我们可以给想要独占一行渲染的list-item组件设置column-span属性即可解决,即list中的columns设置的是多少,在对应的list-item中的column-span就设为多少。

修改如下:

        <div class="item-container">

          <div class="item-content">

            <list class="list" style="columns: 2; layout-type: stagger">

              <list-item type="item5" for="item in staggerlist" style="height:{{item.height}}px;">

                <text class="txt">{{ item.name }}</text>

              </list-item>

              <list-item type="item6" class="load-more" if="{{loadMore}}" style="column-span: 2">

                <progress type="circular"></progress>

                <text>更多...</text>

              </list-item>

            </list>

          </div>

        </div>

截图:

cke_2390.png

Tips:ist-item的column-span数值小于等于其父组件list的columns数值,则表现为占有column-span列宽度的样式;否则,list-item 组件将表现为column-span: 1的样式。

2、  该问题可以设置list的scrollpage属性为true,将list顶部页面中非list部分随list一起滑出可视区域。

实现代码如下:

<template>

  <!-- Only one root node is allowed in template. -->

  <div class="container">

    <tabs>

      <tab-content>

        <div class="item-container">

          <image src="/Common/logo.png" style="width: 100%; height: 200px; margin-top: 20px"></image>

          <image src="/Common/logo.png" style="width: 100%; height: 200px; margin-top: 20px"></image>

          <image src="/Common/logo.png" style="width: 100%; height: 200px; margin-top: 20px"></image>

          <div class="item-content">

            <list class="list" style="columns: 2; layout-type: stagger" scrollpage="true">

              <list-item type="item1" style=" border-radius: 10px; column-span: 2">

                <div style="flex-wrap: wrap">

                  <text class="item" for="textlist">{{ $item }}</text>

                </div>

              </list-item>

              <list-item type="item2" style="column-span: 2">

                <swiper style="width: 100%; height: 200px; margin-top: 20px">

                  <image src="/Common/logo.png" style="width: 100%; height: 200px; margin-top: 20px"></image>

                  <image src="/Common/logo.png" style="width: 100%; height: 200px; margin-top: 20px"></image>

                  <image src="/Common/logo.png" style="width: 100%; height: 200px; margin-top: 20px"></image>

                </swiper>

              </list-item>

              <list-item type="item3" style="margin-top: 20px;  border-radius: 10px; column-span: 2">

                <text style="width: 100px">1</text>

                <text style="width: 100px">2</text>

                <text style="width: 100px">3</text>

              </list-item>

              <!-- <list-item type="item4" for="itemlist">

                <text class="txt" style="height: 150px">{{ $item }}</text>

              </list-item> -->

              <list-item type="item5" for="item in staggerlist" style="height:{{item.height}}px;">

                <text class="txt">{{ item.name }}</text>

              </list-item>

              <list-item type="item6" class="load-more" if="{{loadMore}}" style="column-span: 2">

                <progress type="circular"></progress>

                <text>更多...</text>

              </list-item>

            </list>

          </div>

        </div>

        <!-- tab page2 -->

        <div class="item-container">

          <div class="item-content">

            <list class="list" style="columns: 2; layout-type: stagger">

              <list-item type="item5" for="item in staggerlist" style="height:{{item.height}}px;">

                <text class="txt">{{ item.name }}</text>

              </list-item>

              <list-item type="item6" class="load-more" if="{{loadMore}}" style="column-span: 2">

                <progress type="circular"></progress>

                <text>更多...</text>

              </list-item>

            </list>

          </div>

        </div>

      </tab-content>

      <tab-bar>

        <text class="tab-text">tab1</text>

        <text class="tab-text">tab2</text>

      </tab-bar>

    </tabs>

  </div>

</template>

 

<style>

  .container {

    flex-direction: column;

    justify-content: center;

    align-items: center;

    background-color: rgb(9, 253, 9);

  }

  .tab-bar {

    height: 100px;

    border-color: #bbbbbb;

    color: #bbbbbb;

    border-bottom-width: 1px;

  }

  .tab-text {

    width: 300px;

    text-align: center;

  }

  .tab-text:active {

    color: #f76160;

  }

  .list {

    width: 100%;

    height: 100%;

  }

  .txt {

    width: 100%;

    margin: 10px;

    background-color: white;

  }

  .item {

    height: 150px;

    width: 150px;

    text-align: center;

    border: 1px solid #000000;

    margin: 10px;

  }

  .item-container {

    padding-top: 30px;

    padding-left: 30px;

    padding-right: 30px;

    flex-direction: column;

  }

  .load-more {

    justify-content: center;

    align-items: center;

    height: 100px;

    border-color: #bbbbbb;

    border-bottom-width: 1px;

  }

</style>

 

<script>

  module.exports = {

    data: {

      textlist: ['test1', 'test2', 'test3', 'test4', 'test5', 'test6', 'test7', 'test8'],

      itemlist: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],

      staggerlist: [{ height: 100, name: 'A' }, { height: 300, name: 'B' }, { height: 250, name: 'C' }, { height: 220, name: 'D' }, { height: 300, name: 'E' }, { height: 100, name: 'F' }, { height: 90, name: 'G' }, { height: 170, name: 'A' }, { height: 320, name: 'B' }, { height: 150, name: 'C' }, { height: 120, name: 'D' }, { height: 200, name: 'E' }, { height: 100, name: 'F' }, { height: 60, name: 'G' }],

      loadMore: true,

    },

  }

</script>

标签:name,column,list,height,item,组件,属性
From: https://www.cnblogs.com/mayism123/p/17611019.html

相关文章

  • odoo14接口获取list[]
    odoo14中需要接收list类型odoo原生是不支持的,调用接口是直接报错。所以改一下odoo的接收方法在外面在加一层{}[{'id':1,'name':'123' },{'id':2,'name':'122'}] object_data=json.loads(request)......
  • 基于注解的(属性)依赖注入
    依赖注入(DI):说白了就是对于属性的赋值。基于xml的依赖注入有两种:第一种是基于setter方法的属性注入:<propertyname=""value(ref)=""></property>。第二种是基于构造方法的属性注入:<construct-argname=""value(ref)=""></property>上面两种无论是基于setter的bean属性注......
  • angular组件的生命周期钩子函数
    ​ 上图[4]展示了angular生命周期钩子函数的执行顺序,在此之前,angular会先执行constructor函数。一、基本说明1.constructor用途:初始化组件,设定属性,注入依赖。说明:构造函数中能读取到本组件内部定义的基本变量和函数的值,但是读不到@ContentChildren、@ContentChild、@V......
  • 【8.0】Vue之ref属性
    【ref属性】ref属性,vue提供的,写在标签上可以写在普通标签:在vue中使用this.$refs.名字拿到dom对象,可以原生操作可以写在组件上:在vue中使用this.$refs.名字拿到[组件]对象,组件属性,方法直接使用即可【详解】ref属性是Vue.js中提供的一种特殊属性,它可以用于在标签上......
  • 【标签属性补充】scoped/ref/props
    【一】scoped新建的组件加了scoped,表示样式只在当前组件生效如果不加,子组件都会使用这个样式<stylescoped></style>scoped是Vue.js中的一个样式作用域限定符,用于将样式限制在当前组件中生效,并不会影响子组件或父组件。使用scoped后,样式只会应用于当前组件的......
  • 【7.0】Vue之组件
    【一】组件介绍【1】什么是组件组件就是:扩展HTML元素,封装可重用的代码,目的是复用例如:有一个轮播图,可以在很多页面中使用,一个轮播有js,css,html组件把js,css,html放到一起,有逻辑,有样式,有html组件是在Web开发中常用的一种技术方式,它可以将页面上的不同部分进行封装,形成......
  • 【5.0】Vue之计算属性和监听属性
    【一】计算属性[1]计算属性是通过依赖变量进行缓存的,这意味着计算属性会保存最近一次计算的结果,并且只有在相关的依赖变量发生改变时才会重新计算。[2]计算属性只有在其相关依赖变量发生改变时才会重新求值,这也是它与普通函数的一个主要区别。与函数不同的是,计算属性只在......
  • properties和yaml加载list
    properties和yml加载list方式一:shuhai:test:list:12,13,14@Value(“#{‘${shuhai.test.list}’.split(‘,’)}”)privateListlist;@Value(“${shuhai.test.list}”)privateListlist;方式二:shuhai:test:list:>121314@Valu......
  • 列表(list)的深浅拷贝解析
    一、深浅拷贝如果希望将列表复制一份,通过列表的内置方法copy就可以实现:1s=[[1,2],3,4]2s1=s.copy()3print(s)4print(s1)拷贝出的列表s1与原列表s完全一致。[[1,2],3,4][[1,2],3,4]对s1修改:1s=[[1,2],3,4]2s1=s.copy()3s1[1]='oliver......
  • 前端学习笔记202306学习笔记第四十八天-vant组件的使用3
      ......