[Vuejs]-Vuejs instance – can I have <template> markup outside the <script>tag?

0👍

Your markup inside the script tag is wrong. To create a template, you’d have to export the script, like so:

<template>
  <div class="MyTemplate">
    Your template
  </div>
</template>
<script>
export default {
  name: "MyTemplate"
}
</script>

To then use the template, just import it (import MyTemplate from './MyTemplate.vue') and add it to your components (components: { MyTemplate }) then place it in as <myTemplate>)

Leave a comment