xjdata
V2EX  ›  问与答

请问如何解决深层目录引用的问题[前端]

  •  
  •   xjdata · Oct 21, 2016 · 1859 views
    This topic created in 3691 days ago, the information mentioned may be changed or developed.

    import {foo,bar} from '../../../../foo/bar/models/foobar'

    项目结构按功能划分的。某个页面需要用到上方的组件,因为自身已经有很多层的目录了。

    有什么办法简单点吗?谢谢。

    3 replies  •  2016-10-21 22:45:14 +08:00
    yesmeck
    yesmeck
    Oct 21, 2016❤️1
    1
    两个方案:

    1. https://github.com/michaelzoidl/babel-root-import

    2. 配置 webpack 的 resolve.root http://webpack.github.io/docs/configuration.html#resolve-root 或者 resolve.modulesDirectories
    xjdata
    xjdata
    OP
    Oct 21, 2016
    3
    谢谢!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2822 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 83ms · UTC 10:22 · PVG 18:22 · LAX 02:22 · JFK 05:22
    ♥ Do have faith in what you're doing.