Ext JS编码的base64图像集设置为背景url

问题描述 投票:0回答:1

使用此代码的Ext js和cordova插件

console.log(getBgPicture);

编码图像正确获取。

 setBodyStyle('background:url("'+'data:image/jpeg;base64,'+getBgPicture +'") no-repeat center; background-size: cover'); 

执行过程中将出现此错误

app.js:1 GET data:image / jpeg net :: ERR_INVALID_URL

我尝试了很多方法。如果有人知道,请告诉我。在此先感谢

javascript css cordova extjs encode
1个回答
1
投票

您应该将参数setBodyStyle作为对象与camelCase参数一起使用。

this.setBodyStyle({
    backgroundImage: "url('data:image/jpeg;base64," + getBgPicture + "')",
    backgroundRepeat: "no-repeat",
    backgroundSize: "cover",
    backgroundPosition: "center"
});
© www.soinside.com 2019 - 2024. All rights reserved.