【问题标题】:Function with parameters React-Native带参数的函数 React-Native
【发布时间】:2021-03-10 13:03:22
【问题描述】:

我有这个功能

export default async function get_happy_songs(param) {

    let emotion = param;
    // console.log(emotion)
    ...

    }

在某些时候我想这样做:

let arg = value;
let happy_songs =  await get_happy_songs(arg);

但我知道函数定义语法有问题,所以我应该对我的函数做些什么才能获得该参数?

【问题讨论】:

    标签: react-native parameter-passing react-native-android


    【解决方案1】:

    试试吧,希望对你有用

    export async function get_happy_songs(param) {
    let emotion = param;
    console.log(emotion)
    return true
    }
    
    
    
    
     async componentDidMount() {
     
        let happy_songs =  await get_happy_songs('Love you like  you do');
        console.log(happy_songs)
    }
    

    【讨论】:

      猜你喜欢
      • 2021-06-23
      • 2019-04-07
      • 1970-01-01
      • 1970-01-01
      • 2020-12-26
      • 2016-12-26
      • 2020-02-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多