[英]typescript import dependency with class
為何最好在typescript中導入它並轉換成js:
const randomBytes = require('react-native-randombytes').randomBytes;
我這樣做:
import * as randomBytes from 'react-native-randombyte';
它只會給我:
const randomBytes = require('react-native-randombytes');
您要查找的語法是:
import { randomBytes } from 'react-native-randombyte';
這實質上意味着您只想導入randomBytes
,而不是整個模塊。 有關更多信息,請在此處查看TypeScript文檔:
https://www.typescriptlang.org/docs/handbook/modules.html#import-a-single-export-from-a-module
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.