我創建了一個簡單的組件來渲染來自SVG sprite的圖標。這個組件應該有一個默認的CSS類來全局管理它的樣式(.svg-icon)。另外,我想通過'class'屬性通過類名添加一些依賴於上下文的樣式。Ember 1.13,組件中的類名稱順序
JS:
App.SvgIconComponent = Ember.Component.extend
layoutName: 'components/svg-icon'
classNames: ['svg-icon']
tagName: 'svg'
attributeBindings: ['width', 'height', 'fill'],
width: 16
height: 16
fill: 'currentColor'
模板:
<use xlink:href="#svg-icon-{{name}}"/>
用法:
{{svg-icon name="facebook" class="social__icon" width="14" height="14"}}
HTML輸出:
<svg id="ember1012" width="14" height="14" fill="currentColor" class="social__icon ember-view svg-icon">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#svg-icon-facebook"></use>
</svg>
問題是,Ember將我的默認類(.svg-icon)推入類列表的末尾。但是,爲了避免級聯的一些問題,我需要在課程開始時列出這個類(class =「svg-icon social__icon ember-view」)。是否有可能實現?
我知道,我可以用classNameBindings屬性設置類名,但在這種情況下,我需要使用一些與'class'不同的屬性。使用原生'class'屬性是更可取的。
Thnx。
是否爲了類別在SVG班級列表此事界定?它[不在其他HTML元素上](http://stackoverflow.com/a/8127373/557612)。 – steveax
@steveax哈,我確定這很重要,但事實並非如此!所以我的問題沒有更多的意義。 thnx回覆。 – Kuzzy