Home  >  Article  >  Web Front-end  >  How to use el expression and non-empty judgment in js

How to use el expression and non-empty judgment in js

php中世界最好的语言
php中世界最好的语言Original
2018-05-26 13:42:531495browse

This time I will show you how to use el expressions and non-empty judgments in js. What are the precautions for using el expressions and non-empty judgments in js. The following is a practical case, let's take a look.

After the page jumps, use spring mvc to pass a jsonobject to the front-end page, which needs to be obtained in js and processed.

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 evalfunction to convert the json string into an object.

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

How to use Vue data monitoring method watch

How to create an E-mail address format in JS verify

The above is the detailed content of How to use el expression and non-empty judgment in js. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn