我有三个组件C1、C2、C3映射到路线/c1, /c2/, /c3。
我想阻止组件C3允许(通过浏览器事件处理)返回C2并直接转到C1.
我该如何实现这一目标?
让我假设基本路由 工作正常,并且下面列出的每个文件都放置在网站的根文件夹中。
我的router.js结构如下:
const express = require("express");
const router = express.Router();
router.get("/", (req, res) => {
res.send({ response: "Server is up and running good." }).status(200);
});
router.get("/user", (req, res) => {
res.send({ response: "subroute" }).status(200);
});
router.post('/', (req, res) => {
res.send({ response: 'true' })
})
module.exports = router;
Run Code Online (Sandbox Code Playgroud)
当然,在index.js(主文件)中我指示app上面use的路由器
const router = require('./router');
app.use('/', router);
Run Code Online (Sandbox Code Playgroud)
在Apache2 VirtualHost配置上,我有以下代理配置:
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full
<Proxy *>
Require all …Run Code Online (Sandbox Code Playgroud) 我试图理解为什么以下解决方案在从父级构造函数分配类字段的情况下不起作用的动态:
class B{
constructor(val){
this.a = val;
}
}
class A extends B{
a;
constructor(val){
super(val);
}
}
Run Code Online (Sandbox Code Playgroud)
通过上面的调用new A(1)将返回一个实例,而A.ais undefined。
如果分配是通过命名function而不是超级完成, constructor 则实现将起作用:
class B{
assignMe(val){
this.a = val;
}
}
class A extends B{
a;
constructor(val){
super(null);
super.assignMe(val);
}
}
Run Code Online (Sandbox Code Playgroud)
这正确设置了A.a = 1.
这里有一个更复杂的实现,它代表了我的真实使用场景。
为什么我不能通过使用来实现这一点 constructor ?