Taro 配置 alias

1、在config 目录下找到index.js,在里面的config在配置:

alias: {
    '@/components': 'src/components',
    '@/utils': 'src/utils',
    '@/styles': 'src/styles',
    '@/apis': 'src/apis',
    '@/store': 'src/store',
    "@/images":'src/assets/images'
  }

2、为了让编辑器能识别并提示还需要在项目根目录下的jsconfig.json/txconfig.json下的compilerOptions配置paths:

"paths": {
      "@/components/*":["./src/components/*"],
      "@/utils/*":["./src/utils/*"],
      "@/styles/*":["./src/styles/*"],
      "@/apis/*":["./src/apis/*"],
      "@/store/*":["./src/store/*"],
      "@/images/*":["./src/assets/images/*"]
    }

3、使用

import LoadMore from '@/components/load_more'
import { House } from '@/apis/api_house'
import { queyElementYPosition } from '@/utils/ui'

你可能感兴趣的:(Taro 配置 alias)