1

我正在尝试显示本地文件夹中的一些图像。我通过 JSON 从服务器获取图像名称。基于此,我正在动态构建图像路径。但是,最终的映像路径将被 SC 构建工具更改。我知道我们可以在 css 或视图规范中使用 sc_static() 将其映射到最终路径。如何在以编程方式构建我的 url 时实现该映射(从本地路径到最终路径)。

有什么想法、建议和想法吗?

4

2 回答 2

1

sc_static is not a javascript function, but rather a convention used to tell Abbot (Sproutcore's build tool, written in ruby) to replace it at runtime with a path pointing to the resource passed as first argument to sc_static. Note that this substitution is done by Abbot when the page is refreshed (in dev mode) or when the app is built (in prod mode). It is not a js function at all (use Chrome inspector to see it by yourself).

If you want to use sc_static in JS you can define all resource references as such:

YourApp.loadingIcon=sc_static('loading.png');
YourApp.greenIcon=sc_static('green.png');

and then reference the

YourApp.loadingIcon , YourApp.greenIcon

variables in your code.

于 2012-11-22T11:11:34.270 回答
0

终于在朋友的帮助下找到了答案。sc_static 不是 javascript 函数,它是针对 Sproutcore 的构建工具(Abbot)的函数,用于替换构建后的实际生产路径。因此我们不能在编程中使用 sc_static。

如果我们想要类似的功能,我们已经开发了自己的功能。

于 2012-11-15T12:19:28.227 回答