I'm working on a Gatsby project.
(我正在研究Gatsby项目。)
I am trying to figure out the best way to include external scripts in my application. (我正在尝试找出在应用程序中包含外部脚本的最佳方法。)
Currently I have a 'assets' folder in my 'src' directory with my css and js files. (目前,我的css和js文件在'src'目录中有一个'assets'文件夹。)
I import all of the css files at the top of my layout component and this seems to be working fine. (我将所有css文件导入布局组件的顶部,这似乎工作正常。)
I then use react helmet in that same layout component to include all of my js files. (然后,我在同一布局组件中使用react helmet来包含我的所有js文件。)
I receive the following error message in the browser console: (我在浏览器控制台中收到以下错误消息:)
The script from “http://localhost:8000/assets/js/plugins/jquery-2.2.4.min.js” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.
SyntaxError: expected expression, got '<'
Here's the first 22 lines of my layout component:
(这是我的布局组件的前22行:)
import React from "react"
import { Helmet } from "react-helmet"
import "../assets/css/bootstrap.min.css"
import "../assets/css/fontello.min.css"
import "../assets/css/magnific-popup.min.css"
import "../assets/css/animsition.min.css"
import "../assets/css/style.css"
export default () => (
<div className="global-outer">
<Helmet>
<script
type="text/javascript"
src="../assets/js/plugins/jquery-2.2.4.min.js"
defer="true"
></script>
<script
type="text/javascript"
src="../assets/js/plugins/jquery.magnific-popup.min.js"
defer="true"
></script>
ask by nflauria translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…