禁用侧面板 - Framework7
Disable Sidepanel - Framework7
所以我正在使用 framework7 制作混合移动应用程序。我有一个小问题。好的,我有一个侧面板,当用户打开应用程序时它会自动禁用。当用户登录并被重定向到主视图时,侧面板将被启用。到目前为止,我已经开始工作了。当用户注销时,我无法禁用侧面板。我已经阅读了互联网上的一些问题并尝试了一些事情。
首先,我尝试在用户注销时使用 myApp.allowPanelOpen = false;
。
//Log out
$(document).on("click", '.logout', function(){
myApp.allowPanelOpen = false;
myApp.closePanel();
window.localStorage.clear();
mainView.router.loadPage({url:'index.html', ignoreCache:true, reload:true });
});
这根本不起作用,在我被重定向到索引页面后,我仍然可以通过向右滑动来打开侧面板。
其次,我尝试结合使用 myApp.allowPanelOpen = false;
和 myApp.params.swipePanel = false;
//Log out
$(document).on("click", '.logout', function(){
myApp.allowPanelOpen = false;
myApp.params.swipePanel = false;
myApp.closePanel();
window.localStorage.clear();
mainView.router.loadPage({url:'index.html', ignoreCache:true, reload:true });
});
这也行不通,因为我在用户登录后设置了myApp.allowPanelOpen = true;
和myApp.params.swipePanel= true;
根本打不开面板
有人知道我该怎么做吗?非常感谢任何帮助,这是我目前的代码 运行:
$(document).ready(function(){
// Init App
var myApp = new Framework7({
modalTitle: 'La Cava Express',
material: true,
pushState : true,
swipePanel: "left"
});
//Disable sidepanel by default when app started (this is working)
myApp.allowPanelOpen = false;
// Define Dom7
var $$ = Dom7;
// Init View
var mainView = myApp.addView('.view-main', {});
//Main screen after the user logs in
myApp.onPageInit('promo-catalog', function (page) {
//Enable sidepanel when user starts this page
myApp.allowPanelOpen = true;
});
//Log out
$(document).on("click", '.logout', function(){
myApp.allowPanelOpen = false;
myApp.closePanel();
window.localStorage.clear();
mainView.router.loadPage({url:'index.html', ignoreCache:true, reload:true });
});
});
好的,我让它工作了。在博客 post 上找到的。我最终使用了 myApp.params.swipePanel= false;
参数。我在我想禁用面板的每个页面上都使用了这个参数。每当我想在某个页面上启用它时,我都会使用 myApp.params.swipePanel= 'left';
.
//Log in screen
myApp.onPageInit('login', function (page) {
//Disable sidepanel when user starts this page
myApp.params.swipePanel = false;
});
//Main screen after the user logs in
myApp.onPageInit('promo-catalog', function (page) {
//Enable sidepanel when user starts this page
myApp.params.swipePanel = 'left';
});
仅针对特定页面隐藏面板,否则显示面板代码 注意 页面名称不是您的文件名,它在文件本身中 data-page="yourpage"
var page = e.detail.page;
console.log(page.name);
if(page.name=="services") {
myApp.params.swipePanel = false;
} else
{
myApp.params.swipePanel='left';
}
所以我正在使用 framework7 制作混合移动应用程序。我有一个小问题。好的,我有一个侧面板,当用户打开应用程序时它会自动禁用。当用户登录并被重定向到主视图时,侧面板将被启用。到目前为止,我已经开始工作了。当用户注销时,我无法禁用侧面板。我已经阅读了互联网上的一些问题并尝试了一些事情。
首先,我尝试在用户注销时使用 myApp.allowPanelOpen = false;
。
//Log out
$(document).on("click", '.logout', function(){
myApp.allowPanelOpen = false;
myApp.closePanel();
window.localStorage.clear();
mainView.router.loadPage({url:'index.html', ignoreCache:true, reload:true });
});
这根本不起作用,在我被重定向到索引页面后,我仍然可以通过向右滑动来打开侧面板。
其次,我尝试结合使用 myApp.allowPanelOpen = false;
和 myApp.params.swipePanel = false;
//Log out
$(document).on("click", '.logout', function(){
myApp.allowPanelOpen = false;
myApp.params.swipePanel = false;
myApp.closePanel();
window.localStorage.clear();
mainView.router.loadPage({url:'index.html', ignoreCache:true, reload:true });
});
这也行不通,因为我在用户登录后设置了myApp.allowPanelOpen = true;
和myApp.params.swipePanel= true;
根本打不开面板
有人知道我该怎么做吗?非常感谢任何帮助,这是我目前的代码 运行:
$(document).ready(function(){
// Init App
var myApp = new Framework7({
modalTitle: 'La Cava Express',
material: true,
pushState : true,
swipePanel: "left"
});
//Disable sidepanel by default when app started (this is working)
myApp.allowPanelOpen = false;
// Define Dom7
var $$ = Dom7;
// Init View
var mainView = myApp.addView('.view-main', {});
//Main screen after the user logs in
myApp.onPageInit('promo-catalog', function (page) {
//Enable sidepanel when user starts this page
myApp.allowPanelOpen = true;
});
//Log out
$(document).on("click", '.logout', function(){
myApp.allowPanelOpen = false;
myApp.closePanel();
window.localStorage.clear();
mainView.router.loadPage({url:'index.html', ignoreCache:true, reload:true });
});
});
好的,我让它工作了。在博客 post 上找到的。我最终使用了 myApp.params.swipePanel= false;
参数。我在我想禁用面板的每个页面上都使用了这个参数。每当我想在某个页面上启用它时,我都会使用 myApp.params.swipePanel= 'left';
.
//Log in screen
myApp.onPageInit('login', function (page) {
//Disable sidepanel when user starts this page
myApp.params.swipePanel = false;
});
//Main screen after the user logs in
myApp.onPageInit('promo-catalog', function (page) {
//Enable sidepanel when user starts this page
myApp.params.swipePanel = 'left';
});
仅针对特定页面隐藏面板,否则显示面板代码 注意 页面名称不是您的文件名,它在文件本身中 data-page="yourpage"
var page = e.detail.page;
console.log(page.name);
if(page.name=="services") {
myApp.params.swipePanel = false;
} else
{
myApp.params.swipePanel='left';
}