我有一个文件button.js看起来像这样:
function confirmDeleteDefaultCallback (ev) {
// window.location = ev.data.url;
this.currentRequest = $.ajax({
type: "GET",
url: ev.data.url, ///cd/asset/delete/id/' + assetId
success: function(response) {
console.log(AssetsView);
},
error: function(){
alert("yep error");
}
});
$('#modal').modal('hide');
};
我在另一个名为assets.js的目录中有另一个文件,如下所示:
const INITIAL_PAGINATION = {
current_page: 0,
total_pages: 0,
per_page: 15,
links: {}
};
define([
'fancyBox',
'models/assetSearch/asset',
'marionette',
'marionette.handlebars',
'views/assetSearch/asset'
], function($, AssetModel, Marionette, MarionetteHandlebars, assetView) {
var AssetsView = Marionette.CompositeView.extend({
"view-admin": false,
"can-download": false,
"can-download-low-res": false,
testggg: function() {
console.log("\nggg\n");
},
});
return AssetsView;
}
);
我的问题是,如何从button.js调用testggg函数
我尝试谷歌搜索,但我不知道该搜索什么,因为我是一个新手。看起来像一个简单的任务,但我似乎陷入了困境。
提前致谢。
请注意,在任何浏览器中都不支持JS导入和导出。使用一些JS bundler,如browserify或Webpack(webpack有点难以入手)。它允许您以模块化方式构建代码,然后最终将它们捆绑在一个JS文件中,您可以将其作为外部脚本附加到HTML中。