Polymer 聚合物&x2B;带纸吐司的page.js flash通知
我正在用Polymer构建一个中型应用程序,并使用Polymer初学者工具包启动用于布线的应用程序 我想使用Polymer 聚合物&x2B;带纸吐司的page.js flash通知,polymer,polymer-1.0,page.js,Polymer,Polymer 1.0,Page.js,我正在用Polymer构建一个中型应用程序,并使用Polymer初学者工具包启动用于布线的应用程序 我想使用paper toast元素实现flash消息功能 在其他技术/框架中,这是通过检查路由更改时是否存在属性来实现的。。如果是,则会显示相关的flash/toast消息 怎么。。。使用Polymer&Page.js是否可以复制这种功能?对于更改的路由,Page.js似乎没有任何事件 我能想到的唯一方法是为页面('/route')函数创建一个代理函数,每当我想转到一个新页面时,我必须调用该函数,
paper toast
元素实现flash消息功能
在其他技术/框架中,这是通过检查路由更改时是否存在属性来实现的。。如果是,则会显示相关的flash/toast消息
怎么。。。使用Polymer&Page.js是否可以复制这种功能?对于更改的路由,Page.js似乎没有任何事件
我能想到的唯一方法是为
页面('/route')
函数创建一个代理函数,每当我想转到一个新页面时,我必须调用该函数,然后调用实际的页面
函数。有更好的方法吗?我现在已经实现了如下方法。。。看起来还可以,但如果有人能提出改进建议,请告诉我
在routing.html中
window.addEventListener('WebComponentsReady', function() {
// Assign page to another global object
LC.page = page;
// Define all routes through this new object
LC.page('/login', function () {
app.route = 'login';
app.scrollPageToTop();
});
....
//implement remaining routes
// page proxy... to intercept calls
page = function(path) {
// dispatch event
document.dispatchEvent(new Event('LC.pageChange', {path: path}));
// call the real page
LC.page(path);
};
});
那你想听的地方。。在我的例子中,lc-paper-toast
元素添加到应用程序的index.html
文件中,我现在可以在页面更改时收听该应用程序
ready: function() {
document.addEventListener('LC.pageChange', function(e){
console.log('page change' , e);
}, false);
}
唯一需要注意的是,所有页面更改都必须使用
page('/route')
调用,否则它将无法通过代理。目前我已经实现了如下内容。。。看起来还可以,但如果有人能提出改进建议,请告诉我
在routing.html中
window.addEventListener('WebComponentsReady', function() {
// Assign page to another global object
LC.page = page;
// Define all routes through this new object
LC.page('/login', function () {
app.route = 'login';
app.scrollPageToTop();
});
....
//implement remaining routes
// page proxy... to intercept calls
page = function(path) {
// dispatch event
document.dispatchEvent(new Event('LC.pageChange', {path: path}));
// call the real page
LC.page(path);
};
});
那你想听的地方。。在我的例子中,lc-paper-toast
元素添加到应用程序的index.html
文件中,我现在可以在页面更改时收听该应用程序
ready: function() {
document.addEventListener('LC.pageChange', function(e){
console.log('page change' , e);
}, false);
}
唯一需要注意的是,必须使用page('/route')
调用所有页面更改,否则它将无法通过代理