我有一个访问angularjs应用程序的链接,如下所示:
registerable
当用户打开该链接时,他/她会打开该应用程序。加载应用程序并成功提取查询参数后,我会通过以下代码隐藏这些查询参数:
127.0.0.1:9000/#/doc?abc=def
现在,地址栏中的链接切换为 127.0.0.1:9000 /#/ doc 。如果用户重新加载页面(通过F5或浏览器的重新加载按钮),我想重新加载具有隐藏参数的应用程序。我怎么能这样做?
答案 0 :(得分:1)
您必须存储隐藏的参数,然后在重新加载事件之前恢复它们。由于无法实际捕获重载事件,因此您必须依赖于在卸载窗口之前触发的事件(当用户离开页面或重新加载时)以重新加载这些参数。
public void initFrameBuffer(){
xCache = (int) super.getX(); yCache = (int) super.getY();
widthCache = (int) super.getWidth(); heightCache = (int) super.getHeight();
frameBuffer = new FrameBuffer(Pixmap.Format.RGBA8888, widthCache, heightCache, false);
fboProjectionMatrix.setToOrtho2D(xCache, yCache+heightCache, widthCache, -heightCache);
this.fbBatch = new SpriteBatch();
this.fbBatch.setProjectionMatrix(fboProjectionMatrix);
this.frameBufferReady = true;
}
public void doFrameBuffer(Batch batch, float parentAlpha){
batch.end();
frameBuffer.begin();
fbBatch.begin();
Gdx.gl20.glClearColor(0f, 0.0f, 0.0f, 0.0f);
Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT);
super.draw(fbBatch, parentAlpha);
fbBatch.end();
frameBuffer.end();
batch.begin();
}
public void drawFrameBufferObject(Batch batch, float parentAlpha){
batchColorCache = batch.getColor();
batch.setColor(1.0f, 1.0f, 1.0f, parentAlpha);
batch.draw(frameBuffer.getColorBufferTexture(), getX(), getY());
batch.setColor(batchColorCache);
}
@Override
public void draw(Batch batch, float parentAlpha) {
if (!this.frameBufferReady) initFrameBuffer();
doFrameBuffer(batch, parentAlpha);
drawFrameBufferObject(batch, parentAlpha);
}