DukeScript, why using @JavaScriptResource rather t

2019-09-17 02:20发布

Quote from Using the Knockout API

Define a class JQuery and add the JavaScript-library to your project. Now you can reference it using @JavaScriptResource. This is how you manage JavaScript libraries in DukeScript

Is that any different from including a javascript file with the <script> tag inside an html page? I've tried both and couldn't see why using the annotation @JavaScriptResouce would be any different.

1条回答
别忘想泡老子
2楼-- · 2019-09-17 03:23

The main idea of @JavaScriptRessource is to use it for defining your own Java API over a javascript library, e.g. the API for knockout.

With "script" it would be the users responsibility to provide the correct version. With @JSR the user of the API doesn't have to know anything about the required JS-file. Instead you deliver the correct version with the API. The user of the API only has to deal with Java.

If you use JS only for styling&layout (e.g. bootstrap, etc.) it's fine to just add it via "script" tag.

查看更多
登录 后发表回答