Skip to content

Commit 0330110

Browse files
authored
Update README.md
1 parent ac59755 commit 0330110

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

README.md

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,31 @@ Mustache view use double mustache for variables (message in the example), so the
4545

4646
The `vue` variable generates the javascript code for the view instance creation. The triple mustache `{{{vue}}}`is use for javascript/html code unescaping.
4747

48+
#### With @AutoWired annotation
49+
This technique has the advantage of providing a globale instance of view JS for all the actions of a controller:
50+
```java
51+
@Controller
52+
@RequestMapping("/ui/")
53+
public class UiTest {
54+
55+
@AutoWired
56+
private WueJS vue;
57+
58+
@GetMapping("test")
59+
public String index(ModelMap model) {
60+
vue.addData("message", "Hello world!");
61+
model.put("vue", vue);
62+
return "index";
63+
}
64+
}
65+
```
66+
In this case, you can directly configure **VueJS** in the **application.properties** file:
67+
68+
```bash
69+
springboot.vuejs.delimiters=<%,%>
70+
springboot.vuejs.axios=true
71+
springboot.vuejs.el=v-app
72+
```
4873

4974
#### With @ModelAttribute annotation
5075

@@ -214,15 +239,8 @@ vue.addMethod("submit",Http.postForm("formRef","console.log('submit datas!')"));
214239
HTTP calls from Vue.js to SpringBoot REST backend:
215240

216241
```java
217-
vue.addMethod("loadUser",Http.post("user/","userId","console.log(response)"),"userId");
218-
```
219-
220-
### Configuration
221-
222-
Using Axios:
223-
224-
```java
225-
Http.useAxios();
242+
vue.addMethod("saveUser",Http.post("user/","user","console.log('User added!')"),"user");
243+
vue.addMethod("updateUser",Http.put("user/","user","console.log('User updated!')"),"user");
226244
```
227245

228-
Do not forget to include the corresponding js file.
246+
For axios, Do not forget to include the corresponding js file.

0 commit comments

Comments
 (0)