簡體   English   中英

如何解決 index.js:9 Uncaught TypeError: Cannot read property 'setWallpaper' of undefined?

[英]How to resolve index.js:9 Uncaught TypeError: Cannot read property 'setWallpaper' of undefined?

大家好,我是本機反應的新手,並開始使用壁紙應用程序。 我正在使用react-native-wallpaper-manager構建一個應用程序,但出現以下錯誤:

index.js:9 未捕獲的類型錯誤:無法讀取未定義的屬性“setWallpaper”

索引.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);
 }
 } ;

應用程序.js

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

請幫我解決這個錯誤。

暫無
暫無

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

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