感谢布赖恩和冈特,我做了我自己的通知,由this
我做了所使用的相同,CSS文件的启发,并取得了自定义元素,notification.dart
part of myApp;
class NotificationElement extends HtmlElement {
// Define the custom element tag
static final tag = 'x-Notification';
factory NotificationElement() => new Element.tag(tag);
// Create the element and define its stylesheet
NotificationElement.created() : super.created(){
LinkElement styleSheet = new LinkElement()..rel = "stylesheet"..type="text/css"..href="./style/toastr.css";
document.head.append(styleSheet);
}
var notificationContainer = new Element.html('<div></div>')
..id='notification-container';
var notificationBody = new Element.html('<div></div>')
..classes.add('notification');
var notificationButton = new ButtonElement()
..classes.add('notification-close-button')
..text='x';
var notificationTitle = new Element.html('<div></div>')..classes.add('notification-title');
var notificationMsg = new Element.html('<div></div>')..classes.add('notification-message');
var notificationMsgLabel = new LabelElement();
Element launchElement(type,location,Title,Msg){
notificationButton.onClick.listen((e) => notificationContainer.nodes.remove(notificationBody));
notificationContainer..classes.add('notification-'+location);
notificationBody..classes.add('notification-'+type);
notificationTitle.text=Title;
notificationMsg.innerHtml='<label>'+Msg+'</label>';
notificationBody.nodes..add(notificationButton)..add(notificationTitle)..add(notificationMsg);
notificationContainer.nodes..add(notificationBody);
return (notificationContainer);
}
}
Element mynotification = querySelector('#notification-element');
void CreatefonixNotification(type,location,Title,Msg){
var notifyMe = new Element.tag('x-notification');
notifyMe = notifyMe.launchElement(type,location,Title,Msg);
mynotification.nodes.add(notifyMe);
}
在index.dart
,我注册的元素:
document.registerElement(NotificationElement.tag, NotificationElement);
和index.html中,我加入这个div:
<div id='notification-element'></div>
,并在应用程序的任何地方,我可以把它想:
CreateNotification('error','top-left','Error:','sorry we have some issue!!.')
不管我点击,它出了结果“默认”,所以如果(...)将有权限默认或!默认 – 2014-09-02 18:51:46
您能够发布您的代码更完整的例子吗? – 2014-09-02 19:12:44
没有什么实际的特殊,我想下面的代码只是一旦运行给一个通知,我很少关注的问题发言,thabks – 2014-09-04 23:50:05