DEV Community

Discussion on: Building VueJS Applications with TypeScript

Collapse
 
aihowes profile image
Alex Howes • Edited

Glad I'm not the only one that likes separating template files.

Good to know about the use of a decorator to load in the template file - might give it a try and see what I prefer.

I've been using the below to load in my template files.

@Component({
    template: require('./template.html'),
})
export default class LinkComponent extends AbstractBEMComponent
{
...

Alternatively I've also been using the below:

import template from './template.html';

@Component({
    template
})
export default class LinkComponent extends AbstractBEMComponent
{
...

The second requires the below to be added to .d.ts file as mentioned in your post.

declare module "*.html" 
Collapse
 
georgehanson profile image
George Hanson

That's how I used to do it before, which in my opinion works pretty well. I just prefer the use of the decorator

Collapse
 
aihowes profile image
Alex Howes

Fair enough - I wasn't sure if it was missing out any magic behind the scenes as I'm not using vue-template-loader. :)

Collapse
 
developersubash profile image
developer-subash

can you provide me gihub link please because it is not working on mine it says
You may need an appropriate loader to handle this file type. while compiling can anyone give me idea