在 JavaScript 中,我想在找不到原始图像时显示默认图像。我很确定我错过了一些小东西,但仍然无法弄清楚它是什么。http://jsfiddle.net/yfm6E/
objImg = new Image();
objImg.src = 'http://tiltips.com/wp-content/uploads/2013/02/imgurlogo.jpeg';
if(!objImg.complete)
{
// alert('no');
src = 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQGdkmZ9a8Kk-AX1W3wGWZeXnp2OdbSAzqiWnstiFJGg-ZI04Yc'; //load other image
}else{
// alert('yes');
src= 'http://tiltips.com/wp-content/uploads/2013/02/imgurlogo.jpeg';
}
var layout = Ext.create('Ext.panel.Panel', {
//renderTo: 'layout',
width: 300,
height: 300,
title: 'My Panel', //no title will be blank
html: "<img src= src width='120' height='150'/> ",
renderTo: Ext.getBody() //get the body and display Layout at there
});