var win = Ext.create('Ext.Window',{ 
         width:800, 
         height:600, 
         x:50, 
         y:50, 
         plain: true, 
         //指示标题头的位置,分别为 top,bottom,left,right,默认为top 
         headerPosition: 'top', 
         layout: {
    type: 'table',
    columns: 1
},
         title: '图片浏览',
         defaults:{frame:true,width:400,height:100},
         items:[{title:'', html: '<img width="780" height="580" src="<%=basePath%>goodsimages/'+AGoodsID+'.jpg"/>', rowspan: 1 ,height:800,width:600}]
                
       }); 
       win.show(); 
//目前不知道要怎么传入参数AGoodsID
//请高手们不吝赐教!谢谢!

解决方案 »

  1.   

    这是直接写在jsp页面上的还是单独的js文件?如果是直接写在页面上的,将<img width="780" height="580" src="<%=basePath%>goodsimages/'+AGoodsID+'.jpg"/>中的"AGoodsID"改为你的属性标签就可以。如果是在单独的js文件中,这种写法不规范,Ext是可以用面向对象的方式去设计的。
    应该先定义一个窗体对象"Ext.define("Golden.TestWindow",{});",在里面定义属性和方法:
    Ext.define("Golden.TestWindow",{
    AGoodsID :'',
    getAGoodsID:function(){
    return this.AGoodsID;
    },
    setAGoodsID:function(agi){
    this.AGoodsID=agi;
    },
    createWindow:function(){
        var win = Ext.create('Ext.Window',{ 
            width:800, 
            height:600, 
            x:50, 
            y:50, 
            plain: true, 
            //指示标题头的位置,分别为 top,bottom,left,right,默认为top 
            headerPosition: 'top', 
            layout: {
                type: 'table',
                 columns: 1
            },
            title: '图片浏览',
            defaults:{frame:true,width:400,height:100},
            items:[{title:'', html: '<img width="780" height="580" src="<%=basePath%>goodsimages/'+this.AGoodsID+'.jpg"/>', rowspan: 1 ,height:800,width:600}]    
        }); 
        win.show(); 
    }
    });
    使用时实例化这个类,调用createWindow()前先调用setAGoodsID('xxxx')即可。
    大致如此了,可能代码得调一下,随手打的,未经测试,但是解决方案和规范便是如此了。
      

  2.   

    谢谢楼上的!
    不过现在还是遇到一个问题,就是AGoodsID是数字型的则可以正常调出图片,如果图片名称包含有字母,则不能正常显示图片!
    请问这个问题该如何处理啊?!!
    谢谢啦!
      

  3.   

    包含汉字的不能正常显示图片倒是遇见过,包含字母不显示倒是头一次遇到,是否你的字母里包含需要转义的特殊字符?或者使用alert()打印一下,看文件名是否没有出错,要是出错了,可以尝试使用encodeURI()转码一下看看。