【问题标题】:How to resolve index.js:9 Uncaught TypeError: Cannot read property 'setWallpaper' of undefined?如何解决 index.js:9 Uncaught TypeError:无法读取未定义的属性“setWallpaper”?
【发布时间】:2020-03-29 15:36:14
【问题描述】:

大家好,我是新来的反应原生并开始使用壁纸应用程序。我正在使用react-native-wallpaper-manager 构建一个应用程序和 我收到以下错误:

index.js:9 Uncaught TypeError: Cannot read property 'setWallpaper' of undefined

index.js

var  NativeModules = require('react-native');
var Image  = require('react-native');

module.exports = {
setWallpaper: (source,callback = (res)=>{
    console.log(res);
}) =>{
    NativeModules.WallPaperManager.setWallpaper(Image.resolveAssetSource(source),callback);
 }
 } ;

App.js

 WallPaperManager.setWallpaper({uri: 'img_link', screen: 'both/home/lockscreen'}, (res)=> console.log(res));

请帮我解决这个错误。

【问题讨论】:

    标签: javascript react-native


    【解决方案1】:

    【讨论】:

    • 仅链接的答案应被视为 cmets
    猜你喜欢
    • 2018-12-21
    • 1970-01-01
    • 2021-04-28
    • 2017-07-20
    • 1970-01-01
    • 2020-03-28
    • 2023-04-11
    • 2016-04-22
    • 2015-06-08
    相关资源
    最近更新 更多