后端数据传送到前端,并在前端进行绑定
一:后端代码:
@Autowired
IXssjzbService xssjzbService;
/**
* 入口
* @return 'resources/newStudentEdit'
*/
@GetMapping("/update/{id}")
@DataTranslate
public String update(HttpServletRequest request,@PathVariable String id) {request.setAttribute("rs1", xssjzbService.selectByPrimaryKey(id));
return "xssjzb/newStudentEdit";
}
后端通过 service 层取得一个对象,并传给 rs1.
二:前端代码:
HTML 中:
<script th:inline="javascript">
// var rs1 = Artery.resolveObj(/*[[${rs1}]]*/);
// console.log("rs1:"+rs1)
// rs1 = rs1?rs1 : {};
// this.rs1 = rs1;
// console.log(this.rs1);
vm.$data.rs1= Artery.resolveObj(/*[[${rs1}]]*/);
console.log(vm.$data.rs1)
</script>
获取后端数据:Artery.resolveObj(/[[${rs1}]]/)
传给 JS 中 rs1:vm.$data.rs1