Skip to content

Extend Component options #100

@John0x

Description

@John0x

Hey, I am trying to use the vue-class-component together with nuxt.js.

The problem is, that in a lot of cases I need to give the component an extra option for the layout.
For js, this is how it works:

<template>
  <div>
    <p>Hi from {{ name }}</p>
    <nuxt-link to="/">Home page</nuxt-link>
  </div>
</template>

<script>
export default {
  layout: 'dark',
  asyncData ({ req }) {
    return {
      name: req ? 'server' : 'client'
    }
  }
}
</script>

But how can I do this with the class-component?
My current approach:

<script lang="ts">
import Vue from 'vue';
import Component from 'vue-class-component';

@Component({
  layout: 'admin'
})
export default class AdminPage extends Vue {
}
</script>

But I get the following error:

(12,3): error TS2345: Argument of type '{ layout: string; }' is not assignable to parameter of type 'VueClass'.
  Object literal may only specify known properties, and 'layout' does not exist in type 'VueClass'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions