目标:想要使用ngrok共享网站预览,这会创建一个隧道,从中可以看到我的本地主机,其中包含类似的内容 mywebsite.ngrok.io
问题:我使用WAMP,我的localhost文件夹看起来像这样:
localhostdirectory
|-- website1
|-- website2
|-- etc
Run Code Online (Sandbox Code Playgroud)
要访问我localhost/website1/在浏览器中键入的网站,我想只隧道该URL,可能的解决方案是:
设置一个虚拟主机,我会经历手动设置虚拟主机的麻烦,然后我得到类似于website1.dev的东西,然后我将它作为HTTP请求中的主机头传递给ngrok,如下所示:
ngrok http -host-header=website1.dev 80
Run Code Online (Sandbox Code Playgroud)
我不明白主机头是什么,为什么我不能传递相对网址localhost/website1/,还有什么是重写选项?
有没有更好的方法以更简单的方式实现我的目标,也许通过WAMP别名?
我有一个包含多个react组件的库,并且我想使该库可树状摇动,以便在导入类似
import { Checkbox } from 'my-react-components'
Run Code Online (Sandbox Code Playgroud)
我不导入整个捆绑包。
我的index.js看起来像这样
export { default as Button } from './components/Button'
export { default as Checkbox } from './components/Checkbox'
export { default as FlexView } from './components/FlexView'
export { default as Radio } from './components/Radio'
export { default as Select } from './components/Select'
export { default as TextInput } from './components/TextInput'
export { default as Toggle } from './components/Toggle'
Run Code Online (Sandbox Code Playgroud)
我捆绑使用webpack
module.exports = {
mode: 'production',
entry: './src/index.ts',
output: {
path: path.resolve('./lib'),
filename: 'react-components.js',
libraryTarget: …Run Code Online (Sandbox Code Playgroud) 由于我还需要支持IE11,因此我也需要进行移植node_modules。
这是我在node_modules上使用的babel配置:
presets: [
['@babel/preset-env', { modules: false, useBuiltIns: 'usage' }],
],
Run Code Online (Sandbox Code Playgroud)
我使用这些useBuiltIns选项是因为它给出了错误Symbol is not defined,需要使用polyfill。
但是,此配置在编译时中断,可能是因为它imports在代码中注入了一些内容,这是错误:
基本上,它不喜欢module.exports。那么如何useBuiltIns在供应商捆绑包中使用?
现在,我始终需要在中使用babel polyfill来解决index.html,但这并不理想。
如果我justify-content: space-between在Flex容器中有多个具有该属性的元素,并且我想绝对定位其中一个并从flex流中删除,如下所示:

这适用于Chrome,但不适用于IE和Firefox,因为绝对定位元素被视为0宽度,但仍然在flex流程中:

有没有修复这个保持布局的原因?
我正在查看Bootstrap 4的源代码,我发现他们正在使用es6类以及某种显示模块模式.
以下是从此处获取的代码的简化示例.
const Modal = (($) => {
const NAME = 'modal'
const VERSION = '4.0.0-alpha.3'
...
const Default = {
...
}
class Modal {
constructor(element, config) {
this._config = this._getConfig(config)
this._element = element
...
}
// public
toggle(relatedTarget) {
...
}
show(relatedTarget) {
...
}
hide(event) {
...
}
dispose() {
...
}
// private
_getConfig(config) {
...
}
_showElement(relatedTarget) {
...
}
_enforceFocus() {
...
}
_setEscapeEvent() {
...
}
_setResizeEvent() {
...
} …Run Code Online (Sandbox Code Playgroud) absolute ×1
babeljs ×1
class ×1
css ×1
css-position ×1
ecmascript-6 ×1
flexbox ×1
http ×1
javascript ×1
localhost ×1
ngrok ×1
polyfills ×1
private ×1
reactjs ×1
tree-shaking ×1
virtualhost ×1
wamp ×1
webpack ×1