gpt4 book ai didi

javascript - ExtJS:如何在特定的 `Window` 组件上加载附加脚本?

转载 作者:行者123 更新时间:2023-12-03 01:10:05 25 4
gpt4 key购买 nike

我尝试创建一个窗口,它将显示 AddToAny share buttons 。我需要在此窗口下设置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'
]
});

最佳答案

看看这个 fiddle :

FIDDLE

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>

关于javascript - ExtJS:如何在特定的 `Window` 组件上加载附加脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52235352/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com