Skip to content

Commit 5d0e0f8

Browse files
authored
Update README.md
1 parent 6c98605 commit 5d0e0f8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,23 @@ vue.addMethod("updateUser",Http.put("user/","user","console.log('User updated!')
254254
```
255255

256256
For axios, Do not forget to include the corresponding js file.
257+
258+
### Javascript resource
259+
The javascript code is sometimes too large to be neatly integrated into a java controller.
260+
In this case, it can be delocalized in a javascript file, which can refer to java variables of the controller.
261+
262+
#### resource/static/js/sample.js
263+
```javascript
264+
//resource/static/js/sample.js
265+
console.log("${message}");
266+
```
267+
#### In the java controller
268+
```java
269+
@GetMapping("sample")
270+
public String testJs(@ModelAttribute("vue") VueJS vue) throws IOException {
271+
JavascriptResource js = JavascriptResource.create("sample");
272+
js.put("message", "Hello world!");
273+
vue.addMethod("click", js.parseContent());
274+
return "view";
275+
}
276+
```

0 commit comments

Comments
 (0)