In React I can do something like this:
// parent component
export default (){
return (
<div>
<div>1</div>
<ChildComponent />
<div>5</div>
</div>
);
}
// child component
export default (){
return (
<React.Fragment>
<div>2</div>
<div>3</div>
<div>4</div>
</React.Fragment>
);
};
// compiled html tags in browser .
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
But in Vue , when I've done the same thing , something went difference .
// parent component
<template>
<div>
<div>1</div>
<child-component />
<div>5</div>
</div>
</template>
<script>
import childComponent from 'path/to/childComponent';
export default {
components: { childComponent }
}
</script>
-------------------------------------------------------------
// child component
<template>
<div id='have_to_write_in_vue'>
<div>2</div>
<div>3</div>
<div>4</div>
<div>
</template>
// compiled html tags in browser .
<div>1</div>
<div id='have_to_write_in_vue'>
<div>2</div>
<div>3</div>
<div>4</div>
</div>
<div>5</div>
The difference is that 'DIV' tags are not at same level in Vue . How can I handle this ?
I'm asking this is because of something went wrong when useless nesting appearing.