How to use if in html, The judgment condition has multiple values
-
How to use if in html to set different colors for text according to data, for example, index === 1, text color is red, index === 2, text color is blue, index === 3, text color is green, not found in the document. I have just started working on jsreport, and I am not sure how to use the syntax of jsreport.
-
You should always start with handlebars documentation
https://handlebarsjs.com/guide/If you are familiar with the language and want to quickly search for some solution you can't seem to figure out, try internet search with something like "handlebars switch condition"
https://stackoverflow.com/questions/53398408/switch-case-with-default-in-handlebars-js/53398537The only difference between jsreport and the code snippets you find is that you don't call
Handlebars.registerHelper("someHelper", ...
instead you just add function to the global scope of the jsreport helpers section
function someHelper() { }
Btw your particular problem could be simply solved just with multiple
{{#if}}
sections.
-
Thank you very much. I know how to write it.