2015-10-02 48 views
1

'組件對齊'被識別,但不受尊重。請注意':' - 前綴,因爲必須在父組件上設置此屬性。如何使用Vaadin聲明式UI進行組件對齊?

<v-panel size-full> 
    <v-vertical-layout size-full> 
     <v-horizontal-layout width="100%"> 
     <v-image source="theme://logo.gif" :component-alignment="MIDDLE_RIGHT" /> 
    <v-menu-bar _id="menu" width="100%" :component-alignment="BOTTOM_RIGHT" /> 
     </v-horizontal-layout> 
    </v-vertical-layout> 
</v-panel> 

回答

1

由於每Vaadin book

某些設置,比如在佈局組件的排列,在組件本身都沒有做,但在佈局。以冒號(:)爲前綴的屬性將傳遞給包含組件,並將組件作爲目標參數。例如,對組件c給出的:expand =「1」相當於爲包含的佈局調用setExpandRatio(c,1)。

<v-vertical-layout size-full> 
    <!-- Align right in the containing layout --> 
    <v-label width-auto :right>Hello!</v-label> 
    ... 

它並沒有說什麼,至少從目前來看,是爲了得到一個MIDDLE_RIGHT對齊,您需要分別指定他們兩個,如:

<v-button _id="loginButton" style-name="primary" :middle :right>Sign in</v-button> 
+0

謝謝!請注意,「:component-alignment」不會被報告爲錯誤的語法。 – rmuller

+1

@rmuller沒問題,很高興我能幫上忙。我不確定,但我認爲Vaadin解析器會在運行時默默地忽略這些_extra attributes_,除非您的IDE使用XSD驗證模板,否則在開發過程中也無法知道。 – Morfic