[新增]LayPage limits参数 设置每页数量选择范围
This commit is contained in:
		
							parent
							
								
									8fd74db35d
								
							
						
					
					
						commit
						45c2d4d53e
					
				@ -121,6 +121,34 @@ export default {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
:::
 | 
			
		||||
 | 
			
		||||
::: title 设置每页数量选择范围
 | 
			
		||||
:::
 | 
			
		||||
 | 
			
		||||
::: demo
 | 
			
		||||
 | 
			
		||||
<template>
 | 
			
		||||
  <lay-page :limit="limit" :total="total" :limits="[10,50,100,200]"></lay-page>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
import { ref } from 'vue'
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
  setup() {
 | 
			
		||||
 | 
			
		||||
    const limit = ref(20)
 | 
			
		||||
    const total = ref(100)
 | 
			
		||||
 | 
			
		||||
    return {
 | 
			
		||||
      limit,
 | 
			
		||||
      total
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
:::
 | 
			
		||||
 | 
			
		||||
::: title 每页数量切换事件(limit)
 | 
			
		||||
@ -242,6 +270,7 @@ export default {
 | 
			
		||||
| showRefresh | 显示刷新按钮 | `false` |
 | 
			
		||||
| showSkip    | 显示跳转     | `false` |
 | 
			
		||||
| pages       | 显示切页按钮数量     | `10` |
 | 
			
		||||
| limits       | 切换每页数量的选择项     | `[10,20,30,40,50]` |
 | 
			
		||||
 | 
			
		||||
:::
 | 
			
		||||
 | 
			
		||||
@ -253,6 +282,7 @@ export default {
 | 
			
		||||
| 事件 | 描述     | 参数                  |
 | 
			
		||||
| ---- | -------- | --------------------- |
 | 
			
		||||
| jump | 切换回调 | { current: 当前页面 } |
 | 
			
		||||
| limit | 每页数量变化 | 变化后的值 |
 | 
			
		||||
 | 
			
		||||
:::
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -31,11 +31,7 @@
 | 
			
		||||
    </a>
 | 
			
		||||
    <span v-if="showLimit" class="layui-laypage-limits">
 | 
			
		||||
      <select v-model="inlimit">
 | 
			
		||||
        <option value="10">10 条/页</option>
 | 
			
		||||
        <option value="20">20 条/页</option>
 | 
			
		||||
        <option value="30">30 条/页</option>
 | 
			
		||||
        <option value="40">40 条/页</option>
 | 
			
		||||
        <option value="50">50 条/页</option>
 | 
			
		||||
        <option v-for="val of limits" :key="val" :value="val">{{ val }} 条/页</option>
 | 
			
		||||
      </select>
 | 
			
		||||
    </span>
 | 
			
		||||
    <a v-if="showRefresh" href="javascript:;" class="layui-laypage-refresh">
 | 
			
		||||
@ -65,7 +61,8 @@ const props = withDefaults(
 | 
			
		||||
    showLimit?: boolean | string;
 | 
			
		||||
    showInput?: boolean | string;
 | 
			
		||||
    showRefresh?: boolean | string;
 | 
			
		||||
    pages?: number
 | 
			
		||||
    pages?: number,
 | 
			
		||||
    limits?: number[]
 | 
			
		||||
  }>(),
 | 
			
		||||
  {
 | 
			
		||||
    limit: 10,
 | 
			
		||||
@ -76,9 +73,11 @@ const props = withDefaults(
 | 
			
		||||
    showLimit: true,
 | 
			
		||||
    showInput: false,
 | 
			
		||||
    showRefresh: false,
 | 
			
		||||
    pages: 10
 | 
			
		||||
    pages: 10,
 | 
			
		||||
    limits: () => [10, 20, 30, 40, 50]
 | 
			
		||||
  }
 | 
			
		||||
);
 | 
			
		||||
const limits = ref(props.limits);
 | 
			
		||||
const pages = props.pages / 2
 | 
			
		||||
const inlimit = computed({ get() { return props.limit }, set(v: number) { emit('limit', v) } })
 | 
			
		||||
const maxPage = ref(Math.ceil(props.total / props.limit));
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user