Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sass SCSS中的动态变量_Sass_Extjs6.5 - Fatal编程技术网

Sass SCSS中的动态变量

Sass SCSS中的动态变量,sass,extjs6.5,Sass,Extjs6.5,您好,我想根据Application.js中的变量设置url动态。如果变量为true,则url的路径应如下所示: "https:/asite/resources/mybackground.jpg" 否则,它将直接从应用程序的resources文件夹中获取: "/resources/mybackground.jpg" 所以我需要在url中附加变量。问题是该变量位于我的Application.js文件中,而不是另一个scss文件中 我怎样才能做到这一点 请在下面找到我的css代码: .myvie

您好,我想根据Application.js中的变量设置url动态。如果变量为true,则url的路径应如下所示:

"https:/asite/resources/mybackground.jpg"
否则,它将直接从应用程序的resources文件夹中获取:

"/resources/mybackground.jpg"
所以我需要在url中附加变量。问题是该变量位于我的
Application.js
文件中,而不是另一个scss文件中

我怎样才能做到这一点

请在下面找到我的css代码:

.myviewport::after {
  background: url("/resources/mybackground.jpg") no-repeat;
  position: absolute;
  z-index: -1;
}

您可以在jQuery中执行此操作:

if(need_change) { 
    $('.myviewport').css('background', 'url("the other URL")') 
}

// else you keep the current background

您可以在jQuery中执行此操作:

if(need_change) { 
    $('.myviewport').css('background', 'url("the other URL")') 
}

// else you keep the current background

不能用jQuery更改url吗?类似于
if(need_change){$('.myviewport::after').css('background','url(“另一个url”)}
在哪里实现这段代码?您可以在获取变量值时将其添加到js文件中!我试过了,但没用。背景图像不显示。我在我的控制器中这样做:
init:function(){let need_change=true;if(need_change){console.log('test');$('.myviewport::after').css('background','url('resources/image/mybackground.jpg');no repeat');}
my viewport.js如下:
Ext define('App.viewport',{extend:'Ext.container.Viewport',controller:'viewportcontroller',requires:['App.viewportcontroller',cls:'myviewport',xtype:'myviewport',items:[],});
您不能用jQuery更改url吗?类似于
如果(需要更改){$('.myviewport::after').css('background',url'(“另一个URL”)}
在哪里实现这段代码?当您获得变量值时,您可以将其添加到js文件中!我尝试了它..但不起作用。背景图像不显示。我在我的控制器中这样做:
init:function(){let need_change=true;if(need_change){console.log('test'));$('.myviewport::after').css('background','url('resources/image/mybackground.jpg');}
myviewport.js如下:
Ext.define('App.viewport',{extend:'Ext.container.viewport',controller:'viewportcontroller',要求:['App.viewportcontroller'],cls:'myviewport',xtype:'myviewport',项:[],});