Skip to content

Separate vue component into : *.ts and *.html #8864

@redplane

Description

@redplane

Hi,

I'm using vue-cli 3 and typescript to make my own application.
Everything seemed to be fine until I separated my module into parts: template file and logic file.
I have a component like this:

  • master-layout.component.ts
@Component({
    name: 'master-layout',
    template: require('html-loader!./master-layout.component.html')
})
export default class MasterLayoutComponent extends Vue {
}
  • master-layout.component.html
<div>
    <router-view/>
</div>

Actually, when this component was combined into one *.vue file, it ran smoothly.
But I want to separate the module into 2 parts because in future, code can be longer and longer, therefore, it is hard to track the issue if available.

When I ran the application after changing my code like above, one error was thrown to me:

You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.

Can anyone help ?

Thanks,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions