簡體   English   中英

反應導入語句中的@ 符號是什么意思

[英]What does the @ symbol mean in a react import statement

我正在使用 react js 前端開發 ruby​​ on rails 應用程序。

@在這里代表什么

import ProductCard from '@components/search/ProductCard';

如果您使用的是 Typescript(標簽表明您是),則可以在 tsconfig.json 中設置“路徑映射”

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@": ["./src"],
      "@/*": ["./src/*"],
      "@components": ["./src/components"]
    }
  }
}

這將為“@components”創建一個指向特定文件夾的別名。

在此處閱讀更多相關信息: https : //www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping

它是一個別名,指向要導入的組件的根。 這是表示整個路徑的簡短方法: '/.../.../components/search/ProductCard' 在您的情況下,我認為它也可以作為import ProductCard from '@ProductCard'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM