js中const高級用法 Webpack怎么改html中的js路徑?
Webpack怎么改html中的js路徑?HtmlPlugin插件里配置:varhtmlWebpackPluginrequire(html-webpack-plugin);constCleanWebp
Webpack怎么改html中的js路徑?
HtmlPlugin插件里配置:
varhtmlWebpackPluginrequire(html-webpack-plugin);
constCleanWebpackPluginrequire(clean-webpack-plugin);
don'tpathsToClean[
dist,
];
module.exports{
entry:./src/app.js,
output:{
path:__dirname/dist,
filename:main.[chunkhash].js,
},
plugins:[
funhtmlWebpackPlugin({
template:,
hash:true,
filename:,
minify:{
collapseWhitespace:false
}
}),
futureCleanWebpackPlugin(pathsToClean),
],
module:{
rules:[
{
test:/.css$/,
use:[style-loader,css-loader]
}
]
}
};
jsp中怎么添加dom元素?
是可以直接在html里先添加,也可以用js添加,用js去添加的舉例不勝感激:
ltscriptgt
const(#34ul#34)
for(let i1ilt5i){
const(#34li#34)
li.textContent`item${i}`
(li)
}
(ul)
lt/scriptgt
JavaScript如何獲取數(shù)組維度?
例如一個二維數(shù)組,經(jīng)過處理后能得到3;一個四維數(shù)組處理后能得到4;項目中雖然不廣泛甚至于用不了但要是有大佬明白了的話求指教,有勞。.例如[1,2,[3,4],5,[6,7],8,9]這個數(shù)組當(dāng)經(jīng)過一些代碼這個可以(假如是可以的話)能得到一個i2;,.例如[1,2,[3,4],5,[6,[10,11],7,8],9]這個數(shù)組在一些代碼是可以(要是也可以的話)換取一個i3。
functiongetDepth(arr){
consteleDepths[]
(elea8{
letdepth0
if((ele)){
depthgetDepth(ele)
}
eleDepths.push(depth)
})
return1max(eleDepths)
}
functionmax(arr){
return((accu,curr)gt{
if(currgtaccu)returncurr
returnaccu
})
}
//test
constarr1[1, 2, 3]
constarr2[1, 2, 3,[1,2]]
constarr3[1,[1,[1,2]],3]
constarr4[1,[1,[1,2]],3,4,[1,[1,[1,3]]]]
console.log(getDepth(arr1))//1
console.log(getDepth(arr2))//2
console.log(getDepth(arr3))//3
console.log(getDepth(arr4))//4