This article mainly shares with you how to use el expressions in js. It has a good reference value and I hope it can help everyone. Note that what I want to talk about here is not the use of nested el expressions in jsp, but the use in js.
Scenario:
After the page jumps, use spring mvc to pass a json object to the front-end page, which needs to be obtained in js and processed.
The returned json object:
{"nodes":[{"contactmobile":"15922208502","orderno":"XNH31918062989476864"},{"id":"12198","group":"11","content":"把考虑考虑","modelname":"Company"}],"links":[{"target":"12198","id":"15016","relationType":"公司","source":"12194"}]}
var graph; var flag = "${empty jsonData}"; if(flag!="true"){ graph = eval('(' + '${jsonData}' + ')'); };
There is a note here:
When using el expressions in js, be sure to use quotation marks. If the returned json contains double quotes, then use single quotes to surround the el expression, otherwise, use double quotes.
In addition, pay attention to the writing method of using the eval function to convert the json string into an object.
Related recommendations:
How to use commonly used el expressions
The above is the detailed content of How to use el expression in js. For more information, please follow other related articles on the PHP Chinese website!