0👍
You can create a component and nest it inside another one using slots
here is an example :
Vue.config.productionTip = false
Vue.component('test1',{
template : '<div class="test1">' +
'some content inside test 1' +
'<slot></slot>' +
'</div>'
})
Vue.component('test2',{
template : '<div class="test2">text text text etc.</div>'
})
new Vue({
el :'#app',
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<test1>
<test2></test2>
</test1>
</div>
0👍
I will make that div element into a component,
and put it below where you need to show it (in multiple places).
Then use a variable to control the display (v-show / v-if).
You better not trying to manipulate the DOM with Vue.
- [Vuejs]-What is the difference between importing in <style> and <script> vuejs?
- [Vuejs]-Array changed by Vue(x) after mutating state
0👍
@andypotato, yes you are right, I should not manipulate manually.
I decided to use that appendTo
as jQuery in mount() & continue other things with Vue.js.
Thanks everyone for the help.
- [Vuejs]-How do I pass arguments to an IIFE in vue from vuex store?
- [Vuejs]-Deploy vuejs&laravel 5.8 project
Source:stackexchange.com