簡體   English   中英

ExtJS:如何在特定的“Window”組件上加載附加腳本?

[英]ExtJS: How to load additional script on a specific `Window` component?

我正在嘗試創建一個Window ,它將顯示AddToAny 共享按鈕 我需要在此窗口下設置AddToAny所需的script 我在社交媒體按鈕中搜索了類似的問題。

  • 我了解到Mashup類可以工作。 我創建了一個mixin類,但不幸的是這不起作用。
  • 同樣在項目文件下保存了相關的 JS 庫,並嘗試通過html配置調用它,但這也不起作用。

我怎樣才能達到我的目標?

//Here is related function. 
onMoreShare: function () {
        new Ext.window.Window({
            // requires: ['MyApp.mixins.ShareApps'], //Tried to load JS file to Window
            title: 'More...',
            autoShow: true,
            modal: true,
            padding: 20,
            html: '<a class="a2a_dd" href="https://www.addtoany.com/share"><img src="https://static.addtoany.com/buttons/share_save_171_16.png" width="171" height="16" border="0" alt="Share"></a>\n' +
            // Mixin didn't work; tried original code...
            // '<script async src="https://static.addtoany.com/menu/page.js"></script>\n' +
            // Mixin didn't work; tried to call js file through project
            //'<script type="text/javascript" src="../../../resources/js/addToAny.js"></script>\n'
        });
    }

//Created this `Mashup` based class to load related JS file.
Ext.define('MyApp.mixins.ShareApps', {
    mixins: ['Ext.mixin.Mashup'],

    requiredScripts: [
        '//static.addtoany.com/menu/page.js'
    ]
});

看看這個小提琴:

小提琴

Ext.application({
    name : 'Fiddle',

    launch : function() {
        Ext.widget('window', {
            width: 300,
            height: 250,
            padding: 5,
            title: 'Hello World',
            html: '<div class="a2a_kit a2a_kit_size_32 a2a_default_style"> '+
                  '<a class="a2a_dd" href="https://www.addtoany.com/share"></a> '+
                  '<a class="a2a_button_facebook"></a> '+
                  '<a class="a2a_button_twitter"></a> '+
                  '<a class="a2a_button_google_plus"></a> '+
                  '</div>'
        }).show();
    }
});

索引頁面:

<html>
    <head>
        <script async src="https://static.addtoany.com/menu/page.js"></script>
    </head>
</html>

暫無
暫無

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

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