ktsn/vue-router-layout

Defining the layout via an object errors out

cxl-todd opened this issue · 3 comments

In my home page I have specified a specific layout to use as such:

<script>
import HelloWorld from '@/components/HelloWorld.vue'
export default {
  name: 'home',
  layout: {
    name: 'public',
    props: {
      pageTitle: 'Search',
    },
  },
  components: {
    HelloWorld
  }
}
</script>

This results in no page rendered and this error in the console:

Uncaught (in promise) Error: Cannot find module './[object Object].vue'
    at eval (eval at ./src/layouts lazy recursive ^\.\/.*\.vue$ (app.js:1053), <anonymous>:15:12)

However, specifying the layout using a string works fine:

<script>
import HelloWorld from '@/components/HelloWorld.vue'
export default {
  name: 'home',
  layout: 'public',
  components: {
    HelloWorld
  }
}
</script>

I'd really like to be able to pass props. Any ideas? Thanks!

Note that I'm using v0.1.6. It doesn't appear to pass props at all, regardless. Is that a v0.2 only feature?

@ktsn Any chance you'll add that back into the Vue2 code line? While we all appreciate you staying on top of the changing landscape and having a v3 version front and center, I'd wager most existing code bases are still v2 and would benefit from this change considerably. Especially since it is automatically included in https://github.com/ktsn/vue-cli-plugin-auto-routing which is v2 compatible.