reactjs - How can I properly import TSX files using relative paths?
问题描述
I have a React/Typescript/webpack project.
Everything works fine, except that when I import a 'tsx' file I need to supply the entire path or it will fail to compile.
I want to just write:
import './styles.less';
import { TestComponent } from './TestComponent.tsx';
While the less import works fine, the tsx import fails unless I write:
import './styles.less';
import { TestComponent } from '@src/components/TestComponent.tsx';
解决方案
推荐阅读
- mysql - SQL - 计算另一个表有多少关联记录
- c# - Is there a way to search a list in a SQLite database?
- regex - 如何使用正则表达式重定向部分 URL?
- python - 熊猫从每日数据中获得每月开盘价?
- svg - svg过滤器的适当大小
- android - 当我单击要添加的图像时遇到错误,我的代码中是否存在任何差异
- pandas - 用 pandas 读取制表符分隔的字段,有些行有多个制表符
- dotnetbar - 重新安装窗口后 Dotnetbar 组件不起作用
- jquery - 如何在jquery中动态自动完成
- java - Java中字节数组的Base64,它在PHP中等效