2019-06-10

webpack.config,js里的东西


const path = require('path');

const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {

    entry: './src/index.js',

    output: {

        path: path.resolve(__dirname, 'public'),

        filename: '[hash].js'

    },

    devServer:{

        contentBase:"public",

        inline:true

    },

    module: {

        rules: [

            {

                test:/\.css$/,

                use:['style-loader','css-loader']

            },

            {

                test:/\.(png|jpg|gif|jpeg|mp4)$/,

                use:'file-loader'

            }

        ]

    },

    plugins:[

        new HtmlWebpackPlugin({

            title:"微博怕吃苦",

            template:"./public/index.html",//把谁生成了

            minify:{

                  collapseWhitespace: true,

                  removeComments: true,

                  removeRedundantAttributes: true,

                  removeScriptTypeAttributes: true,

                  removeStyleLinkTypeAttributes: true,

                  useShortDoctype: true

            }

        })

    ]

};




function aaa(opt){ //opt是形参,接收节点,调用后,就接收到了节点,在这里指的是index。js里的a1

    let moren={

        pla:"请输入庄户"      //接收到了节点就可以渲染

    }

    let hebing = Object.assign({}, moren,opt )

console.log(hebing)

hebing.tou.innerHTML = `<input type="text" class="nnn" placeholder="${hebing.pla}">`

}

export default aaa    //抛出这个函数,去接实参




import aaa from "./header"//从.header中获得到aaa这个函数

import "./index.css"

var a1 = {

    tou: document.querySelector(".header")//拿到的html的节点

    // pla:132323

}

aaa(a1)  //调用这个函数,节点是实参传进去

console.log(aaa)import aaa from "./header"//从.header中获得到aaa这个函数

import "./index.css"

var a1 = {

    tou: document.querySelector(".header")//拿到的html的节点

    // pla:132323

}

aaa(a1)  //调用这个函数,节点是实参传进去

console.log(aaa)

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容