react-native - Importing installed node modules vs importing css or other files in React
问题描述
Could someone explain why this:
import React from '../node_modules/react';
is the same as:
import React from 'react';
and this:
import './App.css';
is NOT the same as:
import 'App.css'; or import 'App.css';
in the later example I get a message that the file App.css can not be found in the src directory but it is there.
解决方案
It identifies the modules by name
But files it detects only by path As you will see in the documentation
module-name The module to import from. This is often a relative or absolute path name to the .js file containing the module. Certain bundlers may permit or require the use of the extension; check your environment. Only single quoted and double quoted Strings are allowed.
name Name of the module object that will be used as a kind of namespace when referring to the imports.
推荐阅读
- appium - Browserstack App Automate 需要很长时间才能启动
- python - 如何在 Python 中访问由标签构成的数据?
- liferay-7 - Liferay 7 MVC 组件
- java - 将 Spring boot 1.5 迁移到 2.x 无法启动应用程序
- css - Mapbox GL JS - 样式按钮
- .htaccess - Htaccess 重定向异常
- python - 使用matplotlib的c++实时动画
- sql-server-2016 - SQL2016中如何防止数据屏蔽
- c# - 来自 Microsoft 服务的 Visual Studio 扩展详细信息
- paraview - Paraview 中的 6D 文件类型