[英]How to import html file as template in typescript vue js project as module to use same html file in more than a component?
我正在嘗試將外部 html 文件加載到 typescript 語言的 Vuejs 項目中,但 typescript 編譯器給我的問題如下
ERROR Failed to compile with 1 errors 3:51:57 PM
error in ./src/components/common/dynamic-render.html
我沒有 webpack.config.js 因為這個項目是通過 vue-cli 生成的
我試圖在vue-template-loader ts-loader
的幫助下加載文件,但編譯器仍然拋出同樣的問題
儀表板.vue
import WithRender from "./common/dynamic-render.html";
@WithRender
@Component
我得到以下錯誤
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
您是否按照本文中的說明定義了shims-html.d.ts
?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.