How does Ant Design of Vue's Pagination specify the href value of the a tag in itemRender?

official document Pagination pagination-Ant Design of Vue

its itemRender callback can be used to customize the structure of the page number button, for SEO.
now I want to add an HRef value to the a tag (there is no HRef value by default). How can I do that?

The code below

adds href to the li tag outside the a tag. How to add the href attribute to the a tag?

related codes

      <a-pagination
        hideOnSinglePage
        v-model="currentPage"
        :total="total"
        :itemRender="itemRender"
        @change="pageChange"/>
      itemRender(page, type, ele) {
        let path = page > 1 ? `${this.baseUrl}/${page}` : this.baseUrl;
        ele.context.$attrs.href = path;
        return ele;
      }

current html

<li title="2" tabindex="0" class="ant-pagination-item ant-pagination-item-2 ant-pagination-item-active" href="/galleries/2">
    <a>2</a>
</li>

expected html

<li title="2" tabindex="0" class="ant-pagination-item ant-pagination-item-2 ant-pagination-item-active">
    <a href="/galleries/2">2</a>
</li>

keywords

modify VNode attribute, VNode binding event

Jun.11,2022

I'm sure you can handle the details yourself

itemRender(page, type, originalElement) {
  if (type === "page") {
    return <a href={`/galleries/${page}`}>{page}</a>;
  } else if (type === "prev") {
    return <a href={`/galleries/${this.currentPage - 1}`}></a>;
  } else if (type === "next") {
    return <a href={`/galleries/${this.currentPage + 1}`}></a>;
  }
}

clipboard.png


the goal can also be achieved in this way

      itemRender(page, type, vNode) {
        let path = page > 1 ? `${this.baseUrl}/${page}` : this.baseUrl;
        if (vNode.data) {
          Object.assign(vNode.data, {
            attrs: {
              href: path
            }
          });
        } else {
          vNode.data = {
            attrs: {
              href: path
            }
          }
        }
        let callback = function (e) {
          e.preventDefault();
        };
        if (vNode.data.on) {
          Object.assign(vNode.data.on, {click: callback});
        } else {
          vNode.data.on = {click: callback};
        }

        return vNode;
      }
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea3282-1c35.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea3282-1c35.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?