简体   繁体   中英

How to import html file as template in typescript vue js project as module to use same html file in more than a component?

I am trying to load external html file in to Vuejs project in typescript language but typescript compiler gives me issue as below

ERROR  Failed to compile with 1 errors                                                                                                    3:51:57 PM
 error  in ./src/components/common/dynamic-render.html

I dont have webpack.config.js as this project is generated through vue-cli

I tried to load file with the help of vue-template-loader ts-loader but still compiler throws same issue

Dashboard.vue

import WithRender from "./common/dynamic-render.html";

@WithRender
@Component

I am getting below error

ERROR  Failed to compile with 1 errors                                                                                                    3:51:57 PM
 error  in ./src/components/common/dynamic-render.html

Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

Have you defined shims-html.d.ts as explained in this article ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM