A
A
Adikjoro2017-07-14 04:57:56
JavaScript
Adikjoro, 2017-07-14 04:57:56

How to remove parent element of Vue component after export?

<template>
  <h1>Vue.js</h1>
  <p>Hello</p>
  <img src="">
</template>

When exporting a Vue component template, it throws an error:
template syntax error Component template should contain exactly one root element

Well, of course, you need to wrap it in one element if the template has several parallel tags.
<template>
  <div>
    <h1>Vue.js</h1>
    <p>Hello</p>
    <img src="">
  </div>
</template>

But after export, in the parent component, this main tag interferes (don't ask how, you just need to get rid of it). How can I remove it? Is it possible to apply some kind of unwrap on the component?) And in what property of the component is its html-body? Through console I could not find it at all.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
lavezzi1, 2017-07-14
@lavezzi1

Either so, through the render() function - https://jsfiddle.net/0u4t1nn6/1/
Or access the DOM
or so, if necessary, from the parent
and remove the wrapper.

R
RaulDuke, 2017-07-14
@RaulDuke

Try wrapping your template in a transition-group
You are doing something wrong architecturally
</зануда моде>

A
Adikjoro, 2017-07-14
@Adikjoro

Understood. I stupidly connected Jquery through modules and called $('element').remove() in the mounted hook. But if there are more reasonable options, then be sure to write)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question