2017-02-15 75 views
0

我有以下標記點擊事件:Nativescript FormattedString - 上跨度

<StackLayout paddingLeft="15" paddingRight="15" dock="top" > 
 
    <Label textWrap="true"> 
 
    <Label.formattedText> 
 
     <FormattedString> 
 
     <FormattedString.spans> 
 
      <Span text="By checking 'yes' I understand that this is a legally valid and binding written agreement, and I indicate that I have read, understand, and agree to the terms of my " /> 
 
      <Span text="Agreement. " foregroundColor="#3aba90" tap="viewAgreemnent" /> 
 
      <Span text="Also, by checking 'yes', I certify that I have read and agree to accept electronically the " /> 
 
      <Span text="Privacy Policy." foregroundColor="#3aba90" tap="viewPolicy" /> 
 
     </FormattedString.spans> 
 
     </FormattedString> 
 
    </Label.formattedText> 
 
    </Label> 
 
</StackLayout>

這將創建不同的顏色渲染協議和隱私政策一個文本塊。目標是當用戶點擊它們來執行顯示協議或策略的功能時。問題是輕拍事件不會爲Spans觸發。此事件是否可用於此級別或僅位於頂級標籤級別?

有關如何完成此任何想法?

謝謝。

回答

0

你想幹什麼

<Span text="Privacy Policy." foregroundColor="#3aba90" tap="{{ $parents['Page'].viewPolicy }}" /> https://docs.nativescript.org/core-concepts/data-binding#binding-to-a-parent-binding-context

+0

感謝羅布。這似乎並不奏效。 $ parents ['Page']似乎指向頁面的bindingContext,實際的方法在該上下文中不可用。我錯過了什麼嗎? – dpdragnev

+0

好吧,我剛剛從Telerik確認Span並不是從View派生出來的,並且不支持任何事件。 – dpdragnev