[Vuejs]-Add Vue 3 to CMS generated HTML

0👍

After reading and understanding the documentation, i answer myself.

https://v3.vuejs.org/guide/installation.html#with-a-bundler
See section "In-browser template compilation".

Step 1: Alias vue within webpack

  resolve: {
    alias: {
      vue: "vue/dist/vue.esm-bundler.js"
    }
  }

Step 2: Run Vue 😉

createApp({
  data() {
    return {
      name: 'John Doe'
    }
  },
}).mount('#app')

The definition of template is not necessary. It takes the content from #app.

-1👍

You can do this

createApp({
  data() { return {} },
  template: document.querySelector('#app').innerHTML
}).mount('#app')

Leave a comment