【发布时间】:2017-06-01 09:30:14
【问题描述】:
我正在为我的项目使用最新的create-ract-appversion,并且我有一个custom.js 文件,其中包含CustomFunction 函数。
我需要的是从我的一个组件访问CustomFunctionfunction。
实现这一目标的最佳方法是什么?
将文件导入index.html 如下所示,我有'CustomFunction' is not defined no-undef' 错误:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!-- jQuery import -->
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<!-- Custom Style and JS import -->
<link rel="stylesheet" href="./CustomComponent/custom.css">
<script src="./CustomComponent/custom.js"></script>
这是项目结构:
10 ├── public
11 │ ├── customComponent
12 │ │ ├── custom.js
13 │ │ └── custom.css
14 │ ├── favicon.ico
15 │ ├── index.html
16 │ └── manifest.json
【问题讨论】:
标签: reactjs webpack create-react-app