M
M
Maxim Medvedev2021-10-22 13:54:13
Vue.js
Maxim Medvedev, 2021-10-22 13:54:13

Vue component. How to submit a template?

Good afternoon.
I'm trying to rewrite my app from vue 2 to vue-next. The problem is the following, earlier I could prescribe component templates in the template, that is, of the form

<div id="appAuth">
<router-view></router-view>
<script type="text/x-template" id="my-component">html form</script>
<script type="text/x-template" id="my2-component">html form 2</script>
</div>


and beyond
const my = Vue.component('my-component', {
  template: '#my-component',
...

const my2 = Vue.component('my2-component', {
  template: '#my2-component',


With the update it doesn't work anymore. the question is how to do it right? Depending on the page address, I should show the corresponding block with the form (all different).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Anton, 2021-10-22
@reimax

You can also try
template: document.getElementById().innerHTML

S
Sergey Sokolov, 2021-10-22
@sergiks

with minimal changes - immediately insert an HTML string into the template property:

const my = Vue.component('my-component', {
  template: `
html
   form
  `,
(note these are not single quotes, but backticks)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question