Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个要求,我需要一个 JSON 文件和可以用作 HTML 中的属性值的值。我不确定如何着手解决这个问题。你能帮我么?
通过脚本标签将您的 json 数据文件加载到您的 html 页面中...然后使用本机 javascript 或某些框架(jQuery 是我的首选)到 $(element).attr(name,val)
这可能在一个循环中,该循环遍历您的 json 文件,其中 name 和 val 是当前索引处项目的属性