📜  Framework7通知

📅  最后修改于: 2021-01-02 06:48:16             🧑  作者: Mango

Framework7通知

通知用于显示必需的消息,这些消息看起来像Push(或本地)iOS通知。

Framework7通知的用法:

Index Notification Usage Description
1) Notifications JavaScript API The notifications can also be added or closed with JavaScript by using the related app methods.
2) Notifications Layout Framework7 notifications will be added by using JavaScript.
3) Example iOS Framework7 allows you to use different types of notifications in your iOS layout.
4) Example Material Framework7 notifications can also be used in material layout.

通知JavaScript API

您可以使用以下App方法将JavaScript与Framework7通知一起使用:

myApp.addNotification(parameters):此方法用于添加/显示通知。它接受带有通知参数的必需对象。此方法返回带有动态创建的通知元素的HTMLElement。

myApp.closeNotification(notificationElement):此方法用于关闭指定的通知,该通知接受notificationElement作为必需参数,它是HTMLElement或必需通知的字符串。

添加新通知时,请参阅所需的通知参数:

Index Parameter Type Description
1) title string It represents the notification title and is equal to notificationTitle app’s parameter by default. It is used with iOS theme only.
2) subtitle string It represents the notification subtitle and is equal to notificationSubtitle app’s parameter, by default. It is used with iOS theme only.
3) media string It is the notification media element, which is an HTML string with icon or image. It is equal to notificationMedia app’s parameter by default. It is used with iOS theme only.
4) hold number It is used to close notification automatically after the specified timeout. It is equal to notificationHold app’s parameter by default. It is used with iOS theme only.
5) closeIcon boolean It is disabled to remove close icon from notification. It is equal to notificationCloseIcon app’s parameter by default.
6) button object It is the material notification button, which accepts 3 properties namely text, color and close. It is used with material theme only.
7) closeOnClick boolean If this is set to true then, notification will be closed after clicking on it. It is equal to notificationCloseOnClick app’s parameter by default.
8) additionalClass string It is used to add additionally specified CSS class to notification element.
9) custom string When you want to use notification with custom HTML layout, this parameter is used. The title, subtitle, media and closeIcon parameters will be ignored while using this parameter.
10) onClick function This callback function will be executed after clicking the notification item.
11) onClose function This callback function will be executed when notification is closed.

通知布局

您可以使用JavaScript进行通知。它也可以用于自定义样式。当您添加通知时,Framework7会将特殊通知div与列表块一起放置到正文中。


   ...
   
The custom notification will have the following layout: ...

iOS示例

Framework7可以帮助您在iOS布局中使用不同类型的通知。

例:

让我们以一个示例来演示在Framework7中使用iOS通知:



   
      
      
      
      Notifications
      
      
      
   
   
      
      
      
   

Framework7示例材料

Framework7通知也可以在“材质”布局中使用。

例:

让我们以一个示例来演示Framework7中材料布局通知的用法:



   
      
      
      
      Notifications