Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile Vuejs element

Tags:

vue.js

I'm trying to use Vuejs with some plugins.

There are two components

Vue.component('element-one', {
  template: '<h1>Element ONE</h1>',
}

And the second one :

Vue.component('element-two', {
  template: '<h1>Element TWO</h1>',
}

I want to be able to display the compiled version of element-one in element-two, I know there is something like:

var element = Vue.component('element-one');
new element().$mount().$appendTo('body');

But I'd love to have just the 'mounted' version, and not append it to any place.

Something I can play with in console.log ??

like image 556
kayne Avatar asked May 13 '26 04:05

kayne


1 Answers

I received an answer from https://gitter.im/vuejs/vue. You can get the element by

new element().$mount().$el
like image 113
kayne Avatar answered May 15 '26 04:05

kayne



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!