带URL的ReactJS样式背景图片

时间:2019-03-22 00:26:08

标签: reactjs

对此有误

<body onload="setupZoom();" style={{background:url("/img/bg.jpg") repeat-x #fff}}>

Babel在我删除双引号时抱怨正则表达式,或者是意外的标记,

{ SyntaxError: /Users/robert/multiDomainCMS/views/winwinhost.com/index.jsx: Unexpected token, expected "," (49:72)

  47 |       <title>Unlimited Windows Web Hosting, Unlimited Reseller Hosting, Web hosting & Domain Names</title>
  48 |       </head>
> 49 |       <body onload="setupZoom();" style={{background:url("/img/bg.jpg") repeat-x #fff}}>
     |                                                                         ^
  50 |
  51 |       <div class="d_container">
  52 |         <div class="d_header">
    at Object.raise (/Users/robert/multiDomainCMS/node_modules/@babel/parser/lib/index.js:3831:17)
    at Object.unexpected (/Users/robert/multiDomainCMS/node_modules/@babel/parser/lib/index.js:5143:16)
    at Object.expect (/Users/robert/multiDomainCMS/node_modules/@babel/parser/lib/index.js:5135:28)
    at Object.parseObj (/Users/robert/multiDomainCMS/node_modules/@babel/parser/lib/index.js:6600:14)
    at Object.parseExprAtom (/Users/robert/multiDomainCMS/node_modules/@babel/parser/lib/index.js:6229:21)
    at Object.parseExprAtom (/Users/robert/multiDomainCMS/node_modules/@babel/parser/lib/index.js:3552:20)
    at Object.parseExprSubscripts (/Users/robert/multiDomainCMS/node_modules/@babel/parser/lib/index.js:5862:23)
    at Object.parseMaybeUnary (/Users/robert/multiDomainCMS/node_modules/@babel/parser/lib/index.js:5842:21)
    at Object.parseExprOps (/Users/robert/multiDomainCMS/node_modules/@babel/parser/lib/index.js:5729:23)
    at Object.parseMaybeConditional (/Users/robert/multiDomainCMS/node_modules/@babel/parser/lib/index.js:5702:23)
  pos: 3141,
  loc: Position { line: 49, column: 72 },
  code: 'BABEL_PARSE_ERROR' }

我非常感谢您的帮助,因为我没有任何线索: 我究竟做错了什么?

1 个答案:

答案 0 :(得分:1)

您忘记为background<body onload="setupZoom();" style={{background: 'url("/img/bg.jpg") repeat-x #fff'}}>添加单引号