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)