Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

118
Views
Vue.js Component registration template

Here a very simple component

const MyComponent = Vue.component('my-component', {
   data () {
      // data here...
   },
   methods: {
      // methods here...
   },
   template: '<p>Hello, world !!!</p>'
});

Is it a way to use a external file to write html code <p>Hello, world!</p> instead of the string template ?

I know it is a way with single file components (https://v3.vuejs.org/guide/single-file-component.html).

But unfortunately, i can't follow this way because in my context, i can't use tools like Vue CLI for example

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The value of template in your example can be sourced from anywhere. So its possible to do:

template.js:

export default {
  return "<p>Hello, world!!!</p>"
}

component.js

import template from 'template'

const MyComponent = Vue.component('my-component', {
  template: template,
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!