我正在尝试使用response / xexpr
显示IMG标记这有效:
SWRevealViewController
这不是:
(define (start req)
(response/xexpr
'(html (head (title "Racket Heroku App"))
(body
(h1 "Hello World!")
(div "it works!!!!")
(img ([src "https://docs.racket-lang.org/pict/pict_196.png"]))))))
显示的错误如下:
(define example-url "https://docs.racket-lang.org/pict/pict_196.png")
(define (start req)
(response/xexpr
'(html (head (title "Racket Heroku App"))
(body
(h1 "Hello World!")
(div "it works!!!!")
(img ([src example-url]))))))
我做错了什么?
答案 0 :(得分:1)
您没有评估example-url
变量的值,而是将example-url
作为URL传递。试试这个:
(define example-url "https://docs.racket-lang.org/pict/pict_196.png")
(define (start req)
(response/xexpr
`(html (head (title "Racket Heroku App"))
(body
(h1 "Hello World!")
(div "it works!!!!")
(img ([src ,example-url]))))))
在上面,我使用quasiquoting来评估变量。