I
I
Ivan Tabakerka2018-07-19 13:47:12
Node.js
Ivan Tabakerka, 2018-07-19 13:47:12

How to register a Vue body component using a template from a file?

O Comrades!
I have this code, written according to all the canons of Soviet structuring and Chinese Feng Shui.

import Vue from 'vue'
import App from './App.vue'

import contentPanelTemp from './components/contentPanel.vue'

Vue.component('contentPanel', contentPanelTemp)

new Vue({
  el: '#app',
  render: h => h(App),
  components: {

  }
})

However, I want to register the contentPanel component in the Vue body in order to make the code lighter and not have to write Vue.component() all the time .
All examples on the web use simple type registration:
components: {
   sovietComponent: {
        temlate: '<h1>Привет, Жопа ежа</h1>'
   }
}

But we are not born with a bast, are we? We require the contentPanel.vue file to be used as a template !
So here's how to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Proskurin, 2018-07-19
@IvanTabakerka

So you haven't tried it?

new Vue({
  el: '#app',
  render: h => h(App),
  components: {
     contentPanelTemp
  }
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question