Let's look at the following code first
data = { "siteName": "West Cloud Valley Two", "PM10": "10017", "PM2.5": < Li>{{sitename}}</li> ' + ' <li>{{PM10}}</li> ' + ' <li>{{[\ ' pm2.5\ ']}}</li> '== render (); Console.log (HTML);
The result appears as Template Error
The reason for the analysis may be in the field "PM2.5". In JavaScript. Represents the Get property, such as User.Name, which gets the name property of the user object.
Then there is a solution, let's try the following:
data = { attr: { "siteName": "West Cloud Valley Two", "PM10": "10017", "PM2.5": 17< c11> = ' <li>{{attr.siteName}}</li> ' + ' <li>{{attr. Pm10}}</li> ' + ' <li>{{attr[\ ' pm2.5\ ']}}</li> '== render (data);
Ok! The code runs correctly. The template is parsed correctly.
JavaScript has two ways to access properties, one is through . Access, and one that is accessed using [' Property name ']. So there are fields with special characters that we can access in the second way.
If this article is helpful to you, you can give me a reward.
Technical Exchange QQ Group: 15129679
arttemplate--Call error Arttemplate,syntax error,template error when using arttemplate because of a special format for JSON object properties