Select Templating with Vue.js

The Select field will add a dropdown select box of choices for the content writers to pick from.

Before Reading

This page assumes that you have already included the prismic-vue plugin in your project or that you are using the Prismic Vue.js starter. Check out the Integrating with existing project page to learn how to get setup.

Usage

Here's an example of how to integrate a Select field into your template.
In this example, the Select field has the API ID of category.

Copy
<template>
  <div>
    <p>Category: {{ fields.category }}</p>
  </div>
</template>

<script>
export default {
  data () {
    return {
      fields: {
        category: null
      }
    };
  },
  methods: {
    // This is an example query, the important part is above.
    getContent () {
      this.$prismic.client.getSingle('example')
        .then((document) => {
          this.fields.category = document.data.category;
        })
    }
  },
  created () {
    this.getContent();
  }
};
</script>

To learn more about the Select field check out the user guide.