var addPicWin = Ext.create('Ext.window.Window', { title: '登录背景导入', layout: 'fit', width: 650, height: 455, modal: true, closeAction: 'hide', items: [addPicPanel], listeners: { show: function () { Ext.getCmp("picUpload").getEl().dom.src = ''; } }将这个img标签透明度设置为0设置
时间: 2024-02-10 17:10:36 浏览: 29
可以通过在 `addPicPanel` 组件的 `tbar` 中添加一个 `img` 元素,并将其设置为透明度为 0,来实现上述要求,例如:
```
var addPicPanel = Ext.create('Ext.panel.Panel', {
tbar: [{
xtype: 'image',
src: 'path/to/image',
style: {
opacity: 0
}
}],
// 其他配置项...
});
```
在上面的代码中,我们在 `addPicPanel` 的 `tbar` 中添加了一个 `image` 组件,并将其样式的 `opacity` 属性设置为 0。这样,当 `addPicWin` 显示时,该 `image` 组件的不透明度就会变为 0,从而隐藏它。
注意,如果你需要根据条件动态地改变 `image` 组件的不透明度,可以使用 `setStyle()` 方法,例如:
```
var img = addPicPanel.down('image');
img.setStyle('opacity', 0);
```
上面的代码会将 `image` 组件的不透明度设置为 0。你可以在 `addPicWin` 的 `show` 事件中添加这段代码,以在窗口显示时自动将 `image` 组件的不透明度设置为 0。
相关问题
var addPicWin = Ext.create('Ext.window.Window', { title: '登录背景导入', layout: 'fit', width: 650, height: 455, modal: true, closeAction: 'hide', items: [addPicPanel], listeners: { show: function () { Ext.getCmp("picUpload").getEl().dom.src = ''; } } });我应该如何这段修改代码,使得页面显示一个空白的占位符图片
您可以在 `addPicPanel` 的配置中添加一个 `html` 属性,使用 `<img>` 标签来显示一个空白的占位符图片。修改后的代码如下所示:
```
var addPicPanel = Ext.create('Ext.panel.Panel', {
html: '<img src="https://via.placeholder.com/350x150">'
});
var addPicWin = Ext.create('Ext.window.Window', {
title: '登录背景导入',
layout: 'fit',
width: 650,
height: 455,
modal: true,
closeAction: 'hide',
items: [addPicPanel],
listeners: {
show: function () {
Ext.getCmp("picUpload").getEl().dom.src = '';
}
}
});
```
在这里,我使用了一个 `https://via.placeholder.com` 网站上提供的占位符图片来代替空白的占位符图片,其大小为 `350x150`。您可以根据需要替换为其他图片链接或自己的图片链接。
用Ext js6连接电脑摄像头实现拍照和保存录像的例子
A:
以下是使用Ext JS 6连接电脑摄像头实现拍照和保存录像的示例代码:
1. 引入依赖库:
```
Ext.Loader.setConfig({
enabled: true,
disableCaching: false,
paths: {
'Ext.ux': 'http://cdn.sencha.com/ext/gpl/5.1.1/examples/ux'
}
});
Ext.require([
'Ext.window.Window',
'Ext.ux.IFrame',
'Ext.ux.LiveSearchGridPanel',
'Ext.ux.form.HtmlEditor.Video'
]);
```
2. 声明视频播放器:
```
xtype: 'panel',
title: '视频播放器',
frame: true,
width: 400,
height: 300,
layout: 'fit',
items: {
xtype: 'ux-video',
url: 'http://cdn.sencha.com/ext/gpl/5.1.1/examples/videos/video.mp4',
posterUrl: 'http://cdn.sencha.com/ext/gpl/5.1.1/examples/videos/video-poster.jpg'
}
```
3. 声明摄像头:
```
var video = Ext.create('Ext.ux.Video', {
width: 800,
height: 600,
corsProxyUrl: 'http://robwu.nl/cors-anywhere.html',
enableControls: true,
listeners: {
initialize: function(video) {
var recorder = video.getRecorder();
var controls = Ext.create('Ext.container.Container', {
layout: 'hbox',
items: [{
xtype: 'button',
text: 'Start Recording',
handler: function() {
recorder.start();
}
}, {
xtype: 'button',
text: 'Pause Recording',
handler: function() {
recorder.pause();
}
}, {
xtype: 'button',
text: 'Resume Recording',
handler: function() {
recorder.resume();
}
}, {
xtype: 'button',
text: 'Stop Recording',
handler: function() {
recorder.stop();
}
}]
});
controls.render(video.getId() + '-ct');
}
}
});
Ext.create('Ext.window.Window', {
width: 800,
height: 600,
layout: 'fit',
items: video
}).show();
```
4. 显示摄像头,并添加保存录像和拍照的按钮:
```
var video = Ext.create('Ext.ux.Video', {
// ...
});
Ext.create('Ext.window.Window', {
width: 800,
height: 600,
layout: 'fit',
items: [video, {
xtype: 'toolbar',
dock: 'top',
items: [{
text: 'Save Recording',
handler: function() {
var blob = video.getRecorder().getBlob();
var url = URL.createObjectURL(blob);
Ext.create('Ext.window.Window', {
width: 400,
height: 400,
layout: 'fit',
items: {
xtype: 'ux-iframe',
src: 'saveRecording.php',
method: 'POST',
params: {
'video': {
blob: blob,
name: 'recording.mp4'
}
}
}
}).show();
}
}, {
text: 'Take Snapshot',
handler: function() {
video.snapshot(function(blob) {
var url = URL.createObjectURL(blob);
Ext.create('Ext.window.Window', {
width: 400,
height: 400,
layout: 'fit',
items: [{
xtype: 'image',
src: url
}]
}).show();
});
}
}]
}]
}).show();
```
注意:将“saveRecording.php”替换为服务器端脚本的路径和名称,并根据需要添加相关的参数。