首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >角5+实现智能应用-app旗帜香草JS

角5+实现智能应用-app旗帜香草JS
EN

Stack Overflow用户
提问于 2018-07-31 08:26:37
回答 1查看 1.8K关注 0票数 0

我正在尝试在我的应用程序中使用智能应用程序横幅,但是由于没有在网络上为它打字,我不知道如何使用它的角度。

到目前为止,我已经在我的app.component.ts中找到了这个:

代码语言:javascript
复制
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

我怎么才能把这事做好?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-07-31 10:59:24

因此,将一个简单的JS库实现为一个角度应用程序的过程如下(在这个特定的例子中,也就是说,它将适用于大多数库):

首先,我们使用以下所有选择器导入库:

代码语言:javascript
复制
import * as SmartBanner from "../../node_modules/smart-app-banner/dist/smart-app-banner.js";

然后,在我们的AppComponent类中声明它,然后在构造函数中初始化它。

代码语言:javascript
复制
SmartBanner: any;

constructor() {
    new SmartBanner({
        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: "Author",
        button: "VIEW",
        store: {
            ios: "On the App Store",
            android: "In Google Play"
        },
        price: {
            ios: "FREE",
            android: "FREE"
        }
        // force: 'android' // Uncomment for platform emulation
    });
}

而且效果很好。

如果这是一个性能问题,请任何有进一步的知识,让我知道。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51608777

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档