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