瀏覽代碼

total强制转整型

zhengnaiwen_citu 1 年之前
父節點
當前提交
89a362a12d
共有 1 個文件被更改,包括 4 次插入4 次删除
  1. 4 4
      src/components/Pagination/index.vue

+ 4 - 4
src/components/Pagination/index.vue

@@ -1,13 +1,13 @@
 <!-- 基于 ruoyi-vue3 的 Pagination 重构,核心是简化无用的属性,并使用 ts 重写 -->
 <template>
   <el-pagination
-    v-show="total > 0"
+    v-show="+total > 0"
     v-model:current-page="currentPage"
     v-model:page-size="pageSize"
     :background="true"
     :page-sizes="[10, 20, 30, 50, 100]"
     :pager-count="pagerCount"
-    :total="total"
+    :total="+total"
     :small="isSmall"
     class="float-right mb-15px mt-15px"
     layout="total, sizes, prev, pager, next, jumper"
@@ -33,7 +33,7 @@ const props = defineProps({
   // 总条目数
   total: {
     required: true,
-    type: Number
+    type: [Number, String]
   },
   // 当前页数:pageNo
   page: {
@@ -74,7 +74,7 @@ const pageSize = computed({
 })
 const handleSizeChange = (val) => {
   // 如果修改后超过最大页面,强制跳转到第 1 页
-  if (currentPage.value * val > props.total) {
+  if (currentPage.value * val > +props.total) {
     currentPage.value = 1
   }
   // 触发 pagination 事件,重新加载列表