2017-12-21 6 views
0

私は項目の配列を持っています。私はcustomnameを持つ要素にスタイルクラスを適用したいと思います。Aureliaの要素にコンドルにCSSを適用する

スタイルはどの要素にも適用されません。どのように条件に基づいてスタイルを適用できますか?ここで

var items =["one","two","three"]; 

<li repeat.for="item of items" class="${item == 'one'? 'someclass':''}">${item}</li> 
+0

お知らせ値* 3 *の前後に二重引用符がありません。 ===を使って比較する。 – Benny

+0

いいえ運がベニーです! –

+0

使用している構文が正しいようですが、間違っている可能性のある他のものを探してみてください。あなたはスタイルシートを正しくインポートしていますか?あなたは正しくクラス名を綴っていましたか? –

答えて

1

は例です:あなたがしていることhttps://gist.run?id=ed73adef9c634efbfc4dd109a68ec2c2

app.html

<template> 
    <h1>${message}</h1> 

    <ul ref="ul"> 
    <li repeat.for="item of items" class="${item == 'one' ? 'someclass' : ''}"> 
     ${item} 
    </li> 
    </ul> 

    <h4>Resulting HTML:</h4> 
    <pre><code>${debug}</code></pre> 
</template> 

app.js

export class App { 
    message = 'Hello World!'; 
    items = ["one","two","three"]; 

    get debug() { 
    return this.ul.outerHTML; 
    } 
} 
関連する問題