gpt4 book ai didi

javascript - 用铁刷新Meteor页面 :router always clears route

转载 作者:行者123 更新时间:2023-11-30 00:15:05 26 4
gpt4 key购买 nike

我有一个使用 iron:router 包开发的 Meteor 应用程序。我知道我的用户会有重新加载页面的倾向,因为每个人都喜欢偶尔这样做。

我的问题是,每次重新加载页面时,它都会返回到我的 Meteor 应用程序的主页。

有没有办法让应用在页面重新加载时保持在原来的路线上?

这是我的路线代码:

Router.configure({
layoutTemplate: 'layout', // Defines the layout template
loadingTemplate: 'loading' // Defines the loading template
});

// Add the dataNotFound plugin, which is responsible for
// rendering the dataNotFound template if your RouteController
// data function returns a false value
Router.plugin('dataNotFound', {
notFoundTemplate: 'dataNotFound'
});

Router.route('/', {
name: 'home',
template: 'home'
});

Router.route('/signup');
Router.route('/login');
Router.route('/recoverpassword');
Router.route('/resetpassword');

这是与布局相关的所有内容:

<template name="layout">
{{> navigation}}
{{> yield}}
{{> footer}}
</template>

<head>
<title>Ecclesia.Life</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
</head>

<body>
<!-- Dropdown menu script -->
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
</body>

<template name="navigation">
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="{{pathFor route='home'}}">Ecclesia.Life</a>
</div>

<div class="navbar-collapse collapse" id="navbar-collapse" aria-expanded="false" style="height: 1px;">
<ul class="nav navbar-nav">
<li><a href="{{pathFor route='home'}}"><span class="glyphicon glyphicon-home"></span>&nbsp;&nbsp;&nbsp;&nbsp;Home</a></li>
<li><a id="qrScanner" href="#" onclick="inDevelopment();"><span class="glyphicon glyphicon-qrcode"></span>&nbsp;&nbsp;&nbsp;&nbsp;QR Scanner</a></li>
<script>
$('#qrScanner').click(function() {
alert("Still in in development");
});
</script>
</ul>
<ul class="nav navbar-nav navbar-right">
{{#if currentUser}}
{{#if isInRole 'admin'}}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-cog"></span>&nbsp;&nbsp;&nbsp;&nbsp;Maintenance <span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<a href="/manageusers"><span class="glyphicon glyphicon-user"></span>&nbsp;&nbsp;&nbsp;&nbsp;Manage Users</a>
</li>
<li><a href="/addqrpage"><span class="glyphicon glyphicon-plus"></span>&nbsp;&nbsp;&nbsp;&nbsp;Add QR Page</a></li>
</ul>
</li>
{{/if}}
<li><a href="/@{{currentUser.username}}"><span class="glyphicon glyphicon-user"></span>&nbsp;&nbsp;&nbsp;&nbsp;{{currentUser.profile.firstName}}&nbsp;{{currentUser.profile.lastName}}</a></li>
<li><a id="logout" href="{{pathFor route='login'}}"><span class="glyphicon glyphicon-log-out"></span>&nbsp;&nbsp;&nbsp;&nbsp;Log out</a></li>
{{else}}
<li><a href="{{pathFor route='login'}}"><span class="glyphicon glyphicon-log-in"></span>&nbsp;&nbsp;&nbsp;&nbsp;Log in</a></li>
<li><a href="{{pathFor route='signup'}}"><span class="glyphicon glyphicon-pencil"></span>&nbsp;&nbsp;&nbsp;&nbsp;Sign up</a></li>
{{/if}}
</ul>
</div>
</div>
</nav>

<template name="footer">
<footer class="footer footer-default">
<div class="container-fluid">
<hr />
<p class="text-muted">Copyright &copy; Ecclesia.Life, 2015.</p>
</div>
</footer>
</template>

最佳答案

OK,我整理了小测repo一切都很完美。尝试一下,也许您会发现代码中的差异。如果它仍然不起作用,请发布更多代码(至少是模板定义)以及文件所在的文件夹。还有你安装了什么包。

关于javascript - 用铁刷新Meteor页面 :router always clears route,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35047751/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com