|
页面有一个row组件,内有3列,如何通过lie组件col的bind-style设置background? var Model = function(){
this.callParent();
this.colStyle= justep.Bind.computed(function() {
return this.getColStyle('1');
}, this);
};
Model.prototype.getColStyle = function(fn){
var style = "url('" + require.toUrl("./img/" + fn +".jpg") +"') no-repeat scroll 0 0 / 100% 100% rgba(0, 0, 0, 0);";
console.log("getColStyle,fn="+fn+",style="+style);
return style;
};
col组件的bind-style设置为 {background:colStyle}
<div class="x-col" xid="col1" bind-style="{background:colStyle}"></div>
刷新页面,函数getColStyle执行, colStyle有值 = url('/x5/UI2/v_d85e47c842e1432ba45d7b0d4b62beffl_zh_CNs_d_m/itemshow/img/1.jpg') no-repeat scroll 0 0 / 100% 100% rgba(0, 0, 0, 0);
但页面上图片没有加载
把上述函数的返回值 url('/x5/UI2/v_d85e47c842e1432ba45d7b0d4b62beffl_zh_CNs_d_m/itemshow/img/1.jpg') no-repeat scroll 0 0 / 100% 100% rgba(0, 0, 0, 0); 显示设置到style中,可以加载图片,说明图片路径正常,但通过bind-style方式加载失败
动态设置不显示
手动设置可显示
请问如何通过bind-style动态调整background?
|
|