簡體   English   中英

自定義操作表消息(世博會)

[英]customize action sheet message (Expo)

我正在使用@expo/react-native-action-sheet,我想在道具message中顯示一個按鈕。

例如

import { useActionSheet } from "@expo/react-native-action-sheet"
const { showActionSheetWithOptions } = useActionSheet()

const onPress = () => {

    // Here
    **const message = '<TouchableOpacity><Text>fsdf</Text></TouchableOpacity>'**

    showActionSheetWithOptions(
        {
            message
        },
        (buttonIndex) => {

        }
    )
}

但它不能像我希望的那樣顯示按鈕

在此處輸入圖像描述

對於這個庫,您需要提供一個字符串列表和回調。 在你的情況下,你提供message屬性,它是關於Message to show below the title

這里有一個帶有 3 個按鈕的列表示例:

// Using the provided hook
import { useActionSheet } from '@expo/react-native-action-sheet';

export default Menu() {
  const { showActionSheetWithOptions } = useActionSheet();

  const onPress() => {
    const options = ['Delete', 'Save', 'Cancel'];
    const destructiveButtonIndex = 0;
    const cancelButtonIndex = 2;

    showActionSheetWithOptions({
      options,
      cancelButtonIndex,
      destructiveButtonIndex
    }, (selectedIndex: number) => {
      switch (selectedIndex) {
        case 1:
          // Save
          break;

        case destructiveButtonIndex:
          // Delete
          break;

        case cancelButtonIndex:
          // Canceled
      }});
  }

  return (
    <Button title="Menu" onPress={onPress}/>
  )
};

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM