将src路径backgroundImage从url更改为文件夹CSS ReactJS

时间:2019-04-30 10:15:30

标签: css node.js reactjs material-ui

我正在尝试从Materail-UI按钮图像组件更改ImageBackground。问题在于CSS配置需要backgroundImage,但是它们是通过URL浏览器搜索的,而不是从我的文件系统文件夹中搜索的。

图片帮助链接:

https://imgur.com/2Jhspvq.jpg

https://imgur.com/Vvvww53.jpg

https://imgur.com/cnT4yF4.jpg

;                               Functions
; }-----------------------------------------------------------------------{
GuiToggle()
{
    Sleep, 50
    WinGet, WinState, MinMax, ServiceDeskAssist
    If(WinState==0||WinState==1)
    {
        Gui, -AlwaysOnTop
        WinMinimize, ServiceDeskAssist
        WinWaitNotActive, ServiceDeskAssist
    }
    else if(WinState==-1)
    {
        WinRestore, ServiceDeskAssist
        WinActivate, ServiceDeskAssist
        WinWaitActive, ServiceDeskAssist
        Gui, +AlwaysOnTop
    }
Sleep, 50
}

Toggle(a)
{
    Sleep, 50
    WinGet, WinState, MinMax, % a
    If(WinState==0||WinState==1)
    {
        WinMinimize, % a
        WinWaitNotActive, % a
    }
    else if(WinState==-1)
    {
        WinRestore, % a
        WinActivate, % a
        WinWaitActive, % a
    }
Sleep, 50
}

;                                Hotkeys
; }-----------------------------------------------------------------------{

^x::ExitApp

^z::GuiToggle()

预期结果是从src映像通过文件系统文件夹本地资源管理器而不是通过url进行跨度搜索!

1 个答案:

答案 0 :(得分:0)

您可以在ES5中这样做

 <span
      className={classes.imageSrc}
      style={{
          backgroundImage: `url(require("path to your image file"))`,
      }}
 />

在ES6中,

import image from './image.jpg' //path to file

style={{backgroundImage : `url(${image})`}}