1.0.0 • Published 3 years ago

xiaohong-insert-data-2-html-plugin v1.0.0

Weekly downloads
7
License
MIT
Repository
github
Last release
3 years ago

InsertData2HtmlPlugin 向html中插入全局数据

服务于项目静态化,可以在开发阶段去请求数据,并在构建阶段将数据插入到HTML中

/*插入的形式如下*/
    <head>
    <script>
        ;(function(){
            DEATIL = {
                "data": "data from InsertData2HtmlPlugin"
            }
        })(window)
    </script>
    </head>

参数

params key
openboolean是否开启
urlstring请求的URL 比如 http://127.0.0.1:8900/detail
methodstring请求的方法类型 GET POST 默认POST
headersobject请求头
paramsobject请求参数
keystring全局变量的key 默认DETAIL

使用方式

new InsertData2HtmlPlugin({
    open: true,
    url,
    method: 'POST',
    params,
    key: '*****'
})