gpt4 book ai didi

html - 如何在重新构建、重新代理应用程序中使用资源文件夹中的图像?

转载 作者:行者123 更新时间:2023-12-03 21:58:36 25 4
gpt4 key购买 nike

我有一个使用 Chestnut 创建的应用程序,并且项目中的图像位于以下位置:resources/public/img.png。
我想在我的应用程序中使用这个图像,但是做 [:img {:src "public/img.png"}][:img {:src "./img.png"}]不起作用。什么是正确的 src对于资源文件夹中的图像?

最佳答案

目录部分resources/public是隐含的。您需要访问该文件,如:

(ns demo.core
(:require [clojure.java.io :as io]))

; something like this
(slurp (io/resource "img.png")) ; returns bytes from file
(io/stream (io/resource "img.png")) ; returns in InputStream for file

例如:
(ns tst.demo.core
(:use tupelo.core tupelo.test)
(:require [clojure.java.io :as io]))

(dotest
(let [bytes (slurp (io/resource "sample.json"))]
(spyx (count bytes))))

结果
(count bytes) => 72

关于html - 如何在重新构建、重新代理应用程序中使用资源文件夹中的图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60758763/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com