Route cần có ít nhất một handler hoặc một component

Khi có một yêu cầu tới một route, handler được gọi trước, sau đó tới component
Nếu không có handler nào thì Fresh sẽ tự động thêm một cái mặc định này:

export const handler = {
  get(req, ctx) => ctx.render()
}

Fresh takes whatever you pass into ctx.render(arg) and sets it on props.data. There is no code to ensure that it is correct or anything. It just passes it along. If nothing is passed to ctx.render() then props.data will be undefined

Nguồn:: Routes | Fresh docs

Kết quả được trả về ctx.render(arg) của handler sẽ được truyền lại vào props.data của component


Cập nhật lần cuối : 30 tháng 6, 2024
Tạo : 9 tháng 1, 2024