Koa-router in koa adds styles when clicked like this.

such a navigation clipboard.png
jumps through koarouter, but when you jump like this, give him a style or class name

router.get("/contantus", async ctx => {
  console.log(ctx.response)
  await ctx.render("contantus", {title: ""})
})

router.get("/products", async ctx => {
  await ctx.render("products", {title: ""})
})
HMTL


 <ul class="nav-list">
      <li></li>
      <li class={{active}}><a href="/products"></a> </li>
      <li></li>
      <li><a href="/contantus"></a> </li>
    </ul>
    
    
    
    koa-nunjucks-2 active
    
Sep.03,2021
The owner of

can solve the problem differently. It can be matched according to the current url address. If the current url is products , then add active to the li of the product. There is no need for koa-router to do anything.

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-1eb5be6-2583.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-1eb5be6-2583.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?