【发布时间】:2019-01-07 13:52:51
【问题描述】:
我正在尝试在我的应用中使用 smart-app-banner,但由于网络上没有针对它的类型,我不知道如何在 Angular 中使用它。
到目前为止,我的 app.component.ts 中有这个:
import * as smartBanner from "smart-app-banner";
let smartBannerInstance = smartBanner();
constructor() {
new smartBannerInstance({
daysHidden: 10, // days to hide banner after close button is clicked (defaults to 15)
daysReminder: 20, // days to hide banner after "VIEW" button is clicked (defaults to 90)
// appStoreLanguage: 'us', // language code for the App Store (defaults to user's browser language)
title: "Title",
author: "Authot",
button: "VIEW",
store: {
ios: "On the App Store",
android: "In Google Play"
},
price: {
ios: "FREE",
android: "FREE"
}
// force: 'android' // Uncomment for platform emulation
});
}
但我还是习惯了
Uncaught TypeError: Cannot set property 'options' of undefined at SmartBanner
我怎样才能做到这一点?
【问题讨论】:
-
取决于该模块的捆绑方式,您可能需要
import smartBanner from "smart-app-banner";而不是import * .. -
它不是一个模块,它是一个普通的 js 文件,按照你说的做,我得到
Uncaught TypeError: smart_app_banner_1.default is not a function at eval -
哦,我明白了...但我刚刚意识到你在做
let smartBannerInstance = smartBanner();然后new smartBannerInstance({.. 不应该只是new smartBanner({ ... })吗? -
相同 -
Uncaught TypeError: smart_app_banner_1.default is not a function at eval
标签: javascript angular angular-cli smart-app-banner