1

How do I load a select in vue.js before it's visible. So right now I've this:

methods: {
    getTypes () {
      TypeService.showAll(1) 
            .then(({ data }) => ({
              types: data.types
          }));
    }
  }

Here I receive the types that will be visible in the select like this:

  <select v-model="ride.type" class="Radio__admin">
            <option disabled selected>Type?</option>
            <option v-for="type in types" v-bind:value="type.id">
   </select>     

But when I say:

  init () {
    this.getTypes();
  }

I get the error:

main.js:16526 Uncaught ReferenceError: getTypes is not defined

How should I do this?

1 Answer 1

2

According to documentation methods are first accessible in created hook:

At this stage, the instance has finished processing the options which means the following have been set up: data observation, computed properties, methods, watch/event callbacks.

Sign up to request clarification or add additional context in comments.

Comments

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.