ExtJS 图片面板添加点击跳转功能
您可以在 listeners 的 afterrender 事件中添加点击跳转的功能。修改代码如下:
_getImageShowPanel: function (images, title) {
return {
title: title,
xtype: "fieldset",
border: 0,
height: 130,
anchor: '100%',
items: [{
height: 130,
autoScroll: true,
showSize: false,
showCloseBtn: false,
style: 'margin:2;',
xtype: "ux-image-panel",
anchor: '90%',
listeners: {
afterrender: function (imagePanels) {
Ext.each(images, function (item) {
var image = imagePanels.addImage(item);
image.on('click', function() {
// 跳转到空白页展示图片
window.open(item.url, '_blank');
});
});
}
}
}]
}
}
这段代码在图片面板渲染后,为每个图片添加了点击事件监听器。当用户点击图片时,会使用 window.open() 方法打开一个新的空白页并展示图片。item.url 代表图片的 URL 地址。
原文地址: http://www.cveoy.top/t/topic/b2tq 著作权归作者所有。请勿转载和采集!