Mootools 1.3如何在“注入”函数中获取if语句?

| 我需要以下if代码中的if语句,但如果存在,则无效。有什么办法可以做别的事情吗?
var ele = new Element(\'li\').adopt(

    new Element(\'span.title\', {text:row.title}),
    new Element(\'span.subtitle\').adopt(
        // Need this to work, but its invalid where it is atm
        if(row.subtitle = 1)
        {
            new Element(\'img\', {src:\'images/subTitle.png\'})
        }
    ),
    new Element(\'span.bold\', {text:row.bold}),
);

ele.iject(...
    
已邀请:
        我对MooTools不太熟悉,但是我看不出为什么这行不通:
var subtitle = new Element(\'span.subtitle\');
if (row.subtitle == 1) subtitle.adopt(new Element(\'img\', {src:\'images/subTitle.png\'}));

var ele = new Element(\'li\').adopt(
    new Element(\'span.title\', {text:row.title}),
    subtitle,
    new Element(\'span.bold\', {text:row.bold}),
);
    
        如果FTW立即:
var ele = new Element(\'li\').adopt(

    new Element(\'span.title\', {text:row.title}),
    new Element(\'span.subtitle\').adopt(
        (row.subtitle == 1) ? new Element(\'img\', {src:\'images/subTitle.png\'}) : null
    ),
    new Element(\'span.bold\', {text:row.bold}),
);
    

要回复问题请先登录注册