javascript - 使用 ~ 符号导入/导出
问题描述
我有一个组件文件夹,我在其中定义这样的组件:
export const ResultAlert: FunctionComponent<ResultAlertProps> = ({
severity,
text,
}) => {
const classes = useStyles();
return (
<Alert className={classes.alert} severity={severity}>
{' '}
{text}
</Alert>
);
};
在我的组件文件夹中,我制作了一个index.tsx
文件,上面写着:
export * from './alerts/ResultAlert';
现在,我需要一种方法来使导入工作如下:
import {ResultAlert} from '~/components';
目前,这给了我一个错误
Cannot find module '~/components' or its corresponding type declarations.
我过去看过这项工作,但我不确定如何。我错过了什么?我是否需要为此设置任何其他框架?
解决方案
推荐阅读
- c# - 我如何知道是什么可能导致强制断开与 ASP.NET WebApi 服务的连接?
- postgresql - PostgreSQL:第一个和最后一个之间的计算
- vue.js - vuetify.js:加载了 vue-router 的 v-form-textfield 不可见
- java - 如何检查一个字符串是否包含Java中所有重复的字母?
- python-3.x - 给定一个参数化测试,我怎样才能为所有参数只打印一次消息?
- azureservicebus - Masstransit Azure 服务总线和 DI 请求/响应模型
- ruby-on-rails - 使用 JSONAPI 在请求中发送文件
- c - 将值输入到结构化数组中的数组时出现分段错误
- flutter - 如何在 Flutter 中传递回调
- c# - PeekMessage TranslateMessage DispatchMessage。有没有办法在没有 EXTERN 的 .NET 中本地执行此操作?