我正在尝试仅使用 Webpack 创建一个基本网站。我的目的是拥有一个简单的 URL 结构,例如 example.com/about、example.com/contact。
在 Webpack 中,我可以使用 HTMLWebpackPlugin,但是我需要为每个路由创建一个实例。所以,我的问题是:有没有办法简化这个?
const path = require('path');
const htmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './src/main.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},
devServer: {
port: 5000,
},
plugins: [
new htmlWebpackPlugin({
title: 'Home',
filename: 'index.html',
template: './src/pages/home/index.html',
}),
new htmlWebpackPlugin({
title: 'About',
filename: 'about/index.html',
template: './src/pages/about/index.html',
}),
],
};
Run Code Online (Sandbox Code Playgroud) 我试图了解如何使用jQuery和其他库.我想知道如何使用以下格式创建选择器:
$("#selector").get();
Run Code Online (Sandbox Code Playgroud)
到目前为止,我正在尝试下一个,但我不知道如何运行内部函数(get(),set()):
var $ = (function() {
var jQuery = {
get: function() {
console.log("get() function!!");
return this;
},
set: function() {
console.log("set() function!!");
return this;
}
};
return function(el) {
return document.querySelector(el);
}
})();
Run Code Online (Sandbox Code Playgroud)
我已经阅读了一些关于JavaScript中模块化模式设计的内容,但我并不了解所有内容.