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"},
]
Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.