鍍金池/ 問答/HTML/ vue+typescript創(chuàng)建項目是,提示找不到.html文件

vue+typescript創(chuàng)建項目是,提示找不到.html文件

之前用"vue-html-loader": "^1.0.0", vue+js+webpack
將.vue文件拆成(.html+.css+.js)進行開發(fā)。進入。html文件沒問題。

最近打算嘗試ts.發(fā)現提示找不到
package.json:

"devDependencies": {
//...
"vue-html-loader": "^1.0.0",
}

[ts] 找不到模塊“./demo-list.html”。

clipboard.png

These relative modules were not found:

* ./vue2.html in ./fui-app/view/vue2/vue2.ts
* ./pwa.html in ./fui-app/view/pwa/pwa.ts
* ./index.html in ./fui-app/view/fui/index.ts
* ./main.html in ./src/directives/directives/vtip/main/main.ts, ./src/directives/directives/tooltip/main/main.ts
* ./scroll-menus.html in ./src/fui-components/components/scroll-menus/src/scroll-menus.ts
* ./all-menus.html in ./src/fui-components/components/all-menus/src/all-menus.ts
* ./search.html in ./fui-app/view/search/search.ts
* ./demo-list.html in ./fui-app/view/fui/demo-list/demo-list.ts
回答
編輯回答
薔薇花
import tpl from 'XXX.yy'

這種寫法必須得是目標文件里面有module拋出(export),沒有就

import 'XXX.yy'

vue-html-loader我沒用過,之前用過類似的html-loader,引入方法是直接在頁面對應位置require目標文件。
根據我從npm查看的vue-html-loader官方文檔,也是我說的用法

2018年6月1日 15:44
編輯回答
擱淺

恕我無知,html文件可以import引入?

2018年5月22日 11:03
編輯回答
奧特蛋

添加一個全局的*.d.ts 內容為

declare module "*.html" {
  const content: string
  export default content;
}

然后重啟服務

2018年5月8日 19:09
編輯回答
扯機薄

路徑問題把 把./去掉

2018年4月17日 11:14