简体   繁体   English

何时在 ReactNative 中使用 accessibilityRole='link'?

[英]When to use accessibilityRole='link' in ReactNative?

I have an application with drawer navigation that uses buttons to navigate to different screens.我有一个带有抽屉导航的应用程序,它使用按钮导航到不同的屏幕。 In terms of accessibility, should I use accessibilityRole='button' or accessibilityRole='link' for the buttons.?在可访问性方面,我应该为按钮使用accessibilityRole='button'还是accessibilityRole='link'

React Native AccessibilityRole docs sayReact Native AccessibilityRole文档说

link Used when the element should be treated as a link. link 当元素应被视为链接时使用。

For external links accessibilityRole='link' is clearly the best option.对于外部链接accessibilityRole='link'显然是最佳选择。 But should I use it for internal navigation, too?但是我也应该将它用于内部导航吗?

Note: I do not use deep links in my application.注意:我没有在我的应用程序中使用深层链接。

Thank you for your help.谢谢您的帮助。

The Link component链接组件

renders a component that can navigate to a screen on press.呈现一个可以在按下时导航到屏幕的组件。

The Button component is a component that performs a certain action if the user presses it. Button 组件是在用户按下时执行特定操作的组件。 A Button could be considered a Link if its onPress function navigates to a screen, by definition of the Link component.根据Link组件的定义,如果ButtononPress function 导航到屏幕,则可以将其视为Link The Link could be styled to look exactly like a Button and vice versa. Link的样式可以看起来与Button完全一样,反之亦然。 There would be no difference.没有区别。

If we refer to general URL linking which includes deep linking , then we notice that the link functionality needs a UI component as well in order to function. This could be Markdown, the Link component or again the Button.如果我们参考一般的 URL 链接,其中包括deep linking ,那么我们注意到链接功能也需要一个 UI 组件才能到 function。这可能是 Markdown,链接组件或按钮。

I personally would use accessibilityRole='button' for every UI component that is the actual Button component or functions (and 'looks') like a button in my application ( TouchableOpacity , Pressable , ...), since this is what a user whose disability prevents him from noticing needs to know or wants to visualize.我个人会为每个 UI 组件使用accessibilityRole='button'作为实际Button组件或功能(和'外观')就像我的应用程序中的按钮( TouchableOpacityPressable ,......),因为这是用户的残疾使他无法注意到需要知道或想要形象化。 This includes the Drawer buttons .这包括Drawer buttons

I would use accessibilityRole='link' for text which is styled too look like a link (text with some highlighting) and navigates somewhere (this could be a website as well).我会将accessibilityRole='link'用于样式太像链接(带有一些突出显示的文本)并在某处导航(这也可能是网站)的文本。

In general, I would keep in mind that the user wants to visualize the component.一般来说,我会记住用户想要可视化组件。 While a button, that navigates to a screen, is technically a link by definition of its functionality, it is not a 'typical link' when speaking of visual appereance (but again, we could style our button exactly like that...).虽然导航到屏幕的按钮根据其功能的定义在技术上是一个链接,但在谈到视觉外观时它不是“典型链接”(但同样,我们可以像那样设计我们的按钮......)。

What is generally more important is the accessibilityHint which通常更重要的是accessibilityHint哪个

helps users understand what will happen when they perform an action on the accessibility element when that result is not clear from the accessibility label.帮助用户了解当他们对可访问性元素执行操作时会发生什么,而结果从可访问性 label 中看不清楚。

The 'what will happen if I click' is certainly more important than 'what the component looks like'. “如果我点击会发生什么”肯定比“组件看起来像什么”更重要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我们什么时候应该在 React Native 中使用 `accessibilityRole`? - When should we use `accessibilityRole` in React Native? 输入所有可能的字符串以使用accessibilityRole? - Typing out all possible strings to use accessibilityRole? 在Android中使用ReactNative时axios无法支持gzip - axios could not support gzip when use ReactNative in android 无法在ReactNative中使用StackNavigator - Unable to use StackNavigator in ReactNative 如何在ReactNative中使用异步存储 - How to use asyncstorage in ReactNative 当我使用 reactnative 时,如何在 useEffect 中使用异步等待? - how can i use async await in useEffect when i use reactnative? 如何在ReactNative应用程序中使用reCaptcha? - how to use reCaptcha in ReactNative app? 为什么当您在异步调用的构造函数中使用 setState 时此组件不更新 - ReactJS/ReactNative? - Why does this component not update when you use setState in a constructor in an asynchronous call - ReactJS/ReactNative? 使用AsyncStorage时,为什么会出现“_reactNative.AsyncStorage.setItem不是函数”错误? - Why did I get “_reactNative.AsyncStorage.setItem is not a function” error when use AsyncStorage? 反应性-平面列表-使用滚动条滚动 - reactnative - flatlist - use scrollbar to scroll
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM