Ember.js Nested folder like route (contain slash)

后端 未结 1 1981
攒了一身酷
攒了一身酷 2021-01-13 08:18

I\'m building an app with file manager like functionality with Ember.js. I\'d like the URL for nested folder in the form of \".../#/files/Nested/Inside/\" a

相关标签:
1条回答
  • 2021-01-13 09:02

    Wow, interesting question. It should be possible but I've not tried it myself or seen any examples of this in the wild.

    Under the hood, ember uses the tildeio router and route-recognizer to resolve routes. The route's readme explains how to define more elaborate routes like:

    router.map(function(match) {
      // this will match anything, followed by a slash,
      // followed by a dynamic segment (one or more non-
      // slash characters)
      match("/*page/:location").to("showPage");
    });
    

    So to get nested folders working, you might be able to do something like this:

    FM.Router.map(function() {
      this.resource('folders', { path: '/files' })
      this.resource('folder', { path: '/files/*path' })
    })
    

    Hope this helps.

    0 讨论(0)
提交回复
热议问题