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 ::: demo
<template> <template>
<lay-page limit=10 total=100></lay-page> <lay-page limit=20 total=100></lay-page>
</template> </template>
<script> <script>

View File

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

View File

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

View File

@ -1057,7 +1057,7 @@ a cite {
top: 0; top: 0;
left: 0; left: 0;
right: 0; right: 0;
background-color: #393D49 background-color: #23262E
} }
.layui-layout-admin .layui-side { .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 <a href="javascript:;" class="layui-laypage-next" :class="[currentPage === totalPage ? 'layui-disabled':'']" @click="next()">下一页</a
><span class="layui-laypage-limits" ><span class="layui-laypage-limits"
><select lay-ignore=""> ><select v-model="inlimit">
<option value="10" selected="">{{ limit }} /</option> <option value="10" >10 /</option>
<option value="20">20 /</option> <option value="20" >20 /</option>
<option value="30">30 /</option> <option value="30" >30 /</option>
<option value="40">40 /</option> <option value="40" >40 /</option>
<option value="50">50 /</option> <option value="50" >50 /</option>
</select></span </select></span
><a href="javascript:;" data-page="1" class="layui-laypage-refresh" ><a href="javascript:;" data-page="1" class="layui-laypage-refresh"
><i class="layui-icon layui-icon-refresh"></i></a ><i class="layui-icon layui-icon-refresh"></i></a
><span class="layui-laypage-skip" ><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" type="button"
class="layui-laypage-btn" class="layui-laypage-btn"
@click="jumpPage()"
> >
确定 确定
</button></span </button></span>
>
</div> </div>
</template> </template>
<script setup name="LayPage"></script> <script setup name="LayPage"></script>
<script setup lang="ts"> <script setup lang="ts">
import { defineProps, ref } from 'vue' import { defineProps, ref, watch } from 'vue'
const props = const props =
defineProps<{ defineProps<{
@ -44,8 +44,10 @@ const props =
limit: number 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 currentPage = ref(1)
const currentPageShow = ref(currentPage.value)
const prev = function () { const prev = function () {
if(currentPage.value === 1) { if(currentPage.value === 1) {
@ -64,4 +66,20 @@ const next = function () {
const jump = function (page: number) { const jump = function (page: number) {
currentPage.value = page 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> </script>