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

@@ -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>