我提到了这个本地语言-appList插件。我得到了这个运行时错误,无法读取未定义的属性getPackageManager
。
我在angular2-nativescript构造函数中运行下面的代码
import * as AppList from "nativescript-applist";
// inside the constructor
console.log("First", "Test");
AppList.getInstalledApps(function(apps) {
console.log("Second", "Test");
}, {
withIcons: true
});
在命令提示符下,我无法看到这个日志console.log(“第二个”,“测试”);.I只能看到这个日志console.log(“第一个”,“测试”);
发布于 2017-09-27 06:21:28
该插件似乎与一个角度的项目不兼容,但有一个简单的修复,以使其工作。为了做到这一点,您需要直接修改插件的源代码。要么克隆回购并应用下面的更改,然后npm pack
生成新修改的tgz文件,要么安装插件并直接修改node_modules/nativescript-applist/Apps.android.js
中的代码(这不是一个好方法,因为当删除node_modules文件夹时,所有更改都将被删除)
要使插件以角方式工作,请执行折叠打开node_modules/nativescript-applist/Apps.android.js
--在该方法中移动前两个延迟加载的属性。
例如以前
var androidApp = app.android;
var androidAppCtx = androidApp.context;
function getInstalledListOfApps(callback, cfg) {
// more code follows here
之后
function getInstalledListOfApps(callback, cfg) {
var androidApp = app.android;
var androidAppCtx = androidApp.context;
// more code follows here
你可以走了!
https://stackoverflow.com/questions/46439867
复制相似问题