Skip to content

Please add an example of using an array of string objects to initialize a component. #137

@KingsGithub

Description

@KingsGithub

I"m new to this game so please reserve the flames and ire for another day.

I'm trying to initialize a menu component with an array consisting of objects containing the following:
routeName : string,
menuIconClass : string,
menuOption : string

Component skeleton:

import Vue from 'vue'
import { Component } from 'vue-property-decorator';

interface GeneralMenuItem{
  routename: string; 
  menuiconclass:string; 
  menuoption:string
}
@Component{(
  props: {
   pmenuitems: []  // how to declare this to make it acceptable to Typescript??
  }
) }
export default class GeneralMenuComponent extends Vue {
 pmenuitems: Array;  // Typescript doesn't like an empty array here, i think. How to declare this????
  menuitems : GeneralMenuItem[] ;  // tried various options here without success
  mounted(){
     this.menuitems = pmenuitems;  //THIS is where the problem lies - Typescript rejects assigning an 
   unknown type to a declared type.
  }

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