热门搜索 :
考研考公
您的当前位置:首页正文

hilo游戏开发支持html文件

来源:东饰资讯网

场景需求:
写游戏的时候,有个游戏列表弹层,里面的内容涉及内容较多,如果直接利用hilo的方式写会很累,且效率不高,怎么才能让hilo支持html文件呢 ?啦啦拉,一起来看啊~

html-loader作用 :

将HTML输出为字符串。当编译器要求时,HTML被最小化。

首先需要更新脚手架呀
npm  i  -D  html-loader

webpack配置更改

  module: {
    loaders: [
      {
        test: /\.html$/,
        loader: 'html-loader',
        query: {
          minimize: true,
        }
      }
    ]
  },
  htmlLoader:{       //解决img标签报错的问题
    attrs:[]
  },

index.js

import tpl from "./tpl.html"   //引入html模板
console.info(tpl)   //把模板打印出去

tpl.html

<div>
       <p style="font-size: 14px;">这里是模板内容,这里是模板内容</p>
 </div>
Top