Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/422.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在typescript项目中导入js文件?_Javascript_Reactjs_Typescript_React Native - Fatal编程技术网

Javascript 如何在typescript项目中导入js文件?

Javascript 如何在typescript项目中导入js文件?,javascript,reactjs,typescript,react-native,Javascript,Reactjs,Typescript,React Native,我想在我的react native项目中导入一个js库(react native webview bridge),但我的项目使用typescript,库是js。导入时,提示“[ts]无法找到模块react native webview bridge”。因此我想知道如何将js转换到typescript,或者以其他方式处理。谢谢 import * as WebView from 'react-native-webview-bridge' 从他们的GitHub,我了解到您需要将“WebView”更改

我想在我的react native项目中导入一个
js
库(
react native webview bridge
),但我的项目使用
typescript
,库是
js
。导入时,提示“[ts]无法找到模块
react native webview bridge
”。因此我想知道如何将js转换到
typescript
,或者以其他方式处理。谢谢

import * as WebView from 'react-native-webview-bridge'

从他们的GitHub,我了解到您需要将“WebView”更改为“WebViewBridge”

**CommonJS风格**

var WebViewBridge=require('react-native-webview-bridge')

**ES6/ES2015风格**


从“react native webview bridge”导入WebViewBridge

谢谢你的回答。但是我的项目使用的是typescript,而不是javascript,因此无法直接导入。请参阅此答案:你也可以使用require
require(“脚本”。/lib/d3.js”)在你的打字脚本中。你的意思是?var webView=require('script!react native webView bridge')