简体   繁体   English

添加脚本以反应组件

[英]add script to react component

I'm trying to insert a script code into my react component, but the vscode (ide) swears and does not allow the project to be compiled.我试图将脚本代码插入到我的反应组件中,但 vscode (ide) 发誓并且不允许编译项目。 according to the documentation, I tried to wrap the line with the error in back quotes (``), but then the variables using the above do not see the quoted code根据文档,我尝试用反引号 (``) 将错误行括起来,但是使用上面的变量看不到引用的代码

<Helmet>
     
     <script id="vertex-shader" type="x-shader/x-vertex">
     attribute  vec4 vPosition;
     attribute  vec4 vColor;
     varying vec4 fColor;

     uniform mat4 modelViewMatrix;
     uniform mat4 projectionMatrix;

     void main()
     {
         fColor = vColor; <----  **ERROR Parsing error: Unexpected token, expected** 
         gl_Position = projectionMatrix * modelViewMatrix * vPosition;
     }
   </script>

   <script type="application/ld+json">{`
       {
           "@context": "http://schema.org"
       }
   `}</script>

   <script id="fragment-shader" type="x-shader/x-fragment">

     precision mediump float;

     varying  vec4 fColor;

     void main()
     {
         gl_FragColor = fColor
     }
   </script>
   <script
     src="https://greggman.github.io/webgl-lint/webgl-lint.js"
     crossorigin
   ></script>
   <script
     type="text/javascript"
     src="https://esangel.github.io/WebGL/Common/webgl-utils.js"
   ></script>
   <script
     type="text/javascript"
     src="https://esangel.github.io/WebGL/Common/initShaders.js"
   ></script>
   <script
     type="text/javascript"
     src="https://esangel.github.io/WebGL/Common/MV.js"
   ></script>
   <script type="text/javascript" src="index.js"></script>
   {/* <script>try{Typekit.load({ async: true })}catch(e){}</script> */}

   </Helmet>

you are facing problem with jsx exit port, use ES6 template like this:你正面临 jsx 退出端口的问题,使用这样的 ES6 模板:

<Helmet>
   <script id="vertex-shader" type="x-shader/x-vertex">{`
     attribute  vec4 vPosition;
     attribute  vec4 vColor;
     varying vec4 fColor;

     uniform mat4 modelViewMatrix;
     uniform mat4 projectionMatrix;

     void main()
     {
         fColor = vColor; <----  **ERROR Parsing error: Unexpected token, expected** 
         gl_Position = projectionMatrix * modelViewMatrix * vPosition;
     }
   `}</script>

   <script type="application/ld+json">{`
       {
           "@context": "http://schema.org"
       }
   `}</script>

   <script id="fragment-shader" type="x-shader/x-fragment">{`

     precision mediump float;

     varying  vec4 fColor;

     void main()
     {
         gl_FragColor = fColor
     }
   `}</script>
   ...
</Helmet>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM