Importing html files with es6 template string loader

前端 未结 6 1241
情话喂你
情话喂你 2020-12-09 15:02

I want to import my templates into my js with es6 template string loader. The only difference in my case is that I don\'t want to include css, only html. My code is as follo

6条回答
  •  臣服心动
    2020-12-09 15:40

    The solution posted here is correct. Just adding an info to the error i faced when implementing the solution mentioned.

    I got the error: TS2307: Cannot find module './index3.html'
    This was because of typescript compilation error. The work around was here

    Had to define a file: html.d.ts containing the below

    declare module '*.html' {
      const value: string;
      export default value
    }
    

提交回复
热议问题