问题
I have the following markup:
<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>
This creates one text block with Agreement and Privacy Policy rendered in a different color. The goal is when the user taps them to execute a function displaying the agreement or the policy. The problem is that the tap event does not fire for the Spans. Is this event even available at this level or only on the top Label level?
Any ideas on how to accomplish this?
Thanks.
回答1:
You want to do
<Span text="Privacy Policy." foregroundColor="#3aba90" tap="{{ $parents['Page'].viewPolicy }}" />
https://docs.nativescript.org/core-concepts/data-binding#binding-to-a-parent-binding-context
来源:https://stackoverflow.com/questions/42261311/nativescript-formattedstring-tap-event-on-a-span