How can js's if.elseif be written in ternary expressions?

{{d.gid ==1 ? "layui-badge" : "layui-badge layui-bg-blue"}}

how to write if elseif else? with ternary expressions
the effect should be as follows

if(d.gid == 1) {
    "layui-badge"
}elseif(d.gid == 2){
    "layui-badge layui-bg-blue"
}elseif(d.gid == 3){
    "xxxx"
}else{
    "xxx"
}
Mar.02,2021

d.gid === 1 ? 'layui-badge' : d.gid == 2 ? 'layui-badge layui-bg-blue' : d.gid == 3 ? 'xxxx' : 'xxxxx'

one condition if else or the ternary
two conditions if elseif else
three conditions switch


is it like this:
d.gid = 1? 'layui-badge': d.gid = = 2? 'layui-badge layui-bg-blue': d.gid = = 3? 'xxxx':' xxx'


short-circuit evaluation to write logical judgment is not recommended, after all, the main purpose of the code is to show people.

it's best to use switch


if it's Vue, dealing with it with a method doesn't look much better than writing it this way--

if I didn't forget to say.


it is obvious that ternary expressions should not be used here. Instead, switch should be used. Case. .


is it simple to write directly with a short circuit

(d.gid == 1 && 'layui-badge')||(d.gid == 2 && 'layui-badge layui-bg-blue')||(d.gid == 3 && 'XXX')||'XXXX'
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36476-2c02c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36476-2c02c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?