如何设置option(of select)selected以匹配页面的当前语言?有没有办法内联它并简化它像这样:
(value="en" #{Locale}==='en' ? ',selected="selected"': '')
我在这个网站上尝试了一些答案,但它们似乎没有用.谢谢.
这是观点:
if(#{Locale} ==='en')
option(value="en", selected="selected") #{English}
option(value="bg") #{Bulgarian}
else if(#{Locale} === 'bg')
option(value="en") #{English}
option(value="bg",selected="selected") #{Bulgarian}
Run Code Online (Sandbox Code Playgroud)