亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

React Native 掛鉤使用多個對象

React Native 掛鉤使用多個對象

HUWWW 2023-07-20 11:03:53
我正在嘗試創建一個待辦事項列表應用程序,帶有一個共享按鈕,可以共享您擁有的待辦事項列表。該應用程序已基本完成,我認為代碼的其他部分是無關緊要的,但如果需要,我可以發布它們。我的狀態是這樣的:const [todos, setTodos] = useState([    {todo: 'Add a todo', key: '1'},    ]);我的分享功能是這樣的 -直接取自官方文檔-: const onShare = async () => {    try {      const result = await Share.share({        message:          todos.todo      });      if (result.action === Share.sharedAction) {        if (result.activityType) {          // shared with activity type of result.activityType        } else {          // shared        }      } else if (result.action === Share.dismissedAction) {        // dismissed      }    } catch (error) {      alert(error.message);    }  };我在其中渲染按鈕并調用函數:<Button color= 'orange' title={'Share'} onPress={onShare}/>我的問題出在部分(第二個代碼塊)中,我無法聯系到該州內的message:個人。這可能是最簡單的問題,但我找不到方法......todotodos請幫助 :)
查看完整描述

1 回答

?
青春有我

TA貢獻1784條經驗 獲得超8個贊

嘗試這種將待辦事項的所有數據包裝在字符串中的方法


const justTodos = todos.map(item => item.todo);

const result = await Share.share({

        message: JSON.stringify(justTodos)

})


查看完整回答
反對 回復 2023-07-20
  • 1 回答
  • 0 關注
  • 120 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號