1

I've been trying to use an external array in my VueJs code, but I've been running into problems

Here's my code:

import iconsData from 'components/iconsData.js';
  export default{
    data(){
      return{
        activeIcon: '',
        icons : iconsData
      }
    },
    methods: {
      consoleIcons(){
        console.log(this.icons)
      }
    }
  }

iconsData.js is:


export const iconsData = [
   {"name": "material-icons"},
   {"name": "eva-icons"},
]

but all I get is a warning:


export 'default' (imported as 'iconsData') was not found in 'components/iconsData.js' (possible exports: iconsData)

any help is appreciated.

1

1 Answer 1

3

The error is tied to the import. Currently, iconsData.js exports an object { iconsData: [...] }. Thus, you need to be more specific about what exactly you are trying to import:

import { iconsData } from 'components/iconsData.js';

Alternatively, this would also work:

export default [
   {"name": "material-icons"},
   {"name": "eva-icons"},
]
1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Dec 21, 2021 at 10:32

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.