feat(page): 初步完成 page 组件, 存在类型转换问题待处理

This commit is contained in:
就眠仪式 2021-10-09 20:19:45 +08:00
parent 831bad517f
commit a1ddef595b
5 changed files with 33 additions and 15 deletions

View File

@ -1,7 +1,7 @@
::: demo
<template>
<lay-page limit=10 total=100></lay-page>
<lay-page limit=20 total=100></lay-page>
</template>
<script>

View File

@ -1,7 +1,7 @@
<template>
<div class="width:100%;height:300px">
<lay-layout>
<lay-header>
<lay-header style="background:#393D49">
<lay-logo>
<img src="../assets/logo.png" />
</lay-logo>

View File

@ -1,6 +1,6 @@
{
"name": "@layui/layui-vue",
"version": "0.0.14",
"version": "0.0.15",
"description": "a component library for Vue 3 base on layui-vue",
"main": "lib/layui-vue.umd.js",
"module": "lib/layui-vue.es.js",

View File

@ -1057,7 +1057,7 @@ a cite {
top: 0;
left: 0;
right: 0;
background-color: #393D49
background-color: #23262E
}
.layui-layout-admin .layui-side {

View File

@ -15,28 +15,28 @@
<a href="javascript:;" class="layui-laypage-next" :class="[currentPage === totalPage ? 'layui-disabled':'']" @click="next()">下一页</a
><span class="layui-laypage-limits"
><select lay-ignore="">
<option value="10" selected="">{{ limit }} /</option>
<option value="20">20 /</option>
<option value="30">30 /</option>
<option value="40">40 /</option>
<option value="50">50 /</option>
><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>
</select></span
><a href="javascript:;" data-page="1" class="layui-laypage-refresh"
><i class="layui-icon layui-icon-refresh"></i></a
><span class="layui-laypage-skip"
>到第<input type="text" min="1" value="1" class="layui-input" /><button
>到第<input type="text" v-model="currentPageShow" class="layui-input" /><button
type="button"
class="layui-laypage-btn"
@click="jumpPage()"
>
确定
</button></span
>
</button></span>
</div>
</template>
<script setup name="LayPage"></script>
<script setup lang="ts">
import { defineProps, ref } from 'vue'
import { defineProps, ref, watch } from 'vue'
const props =
defineProps<{
@ -44,8 +44,10 @@ const props =
limit: number
}>()
const totalPage = ref(props.total / props.limit)
const inlimit= ref(props.limit)
const totalPage = ref(Math.ceil(props.total / inlimit.value))
const currentPage = ref(1)
const currentPageShow = ref(currentPage.value)
const prev = function () {
if(currentPage.value === 1) {
@ -64,4 +66,20 @@ const next = function () {
const jump = function (page: number) {
currentPage.value = page
}
const jumpPage = function() {
currentPage.value = currentPageShow.value
}
watch(inlimit, function() {
currentPage.value = 1
totalPage.value = Math.ceil(props.total / inlimit.value)
})
watch(currentPage, function() {
currentPageShow.value = currentPage.value
})
</script>