- Framework7 教程
- Framework7 - 首頁
- Framework7 - 概述
- Framework7 - 環境
- Framework7 元件
- Framework7 - 佈局
- Framework7 - 導航欄
- Framework7 - 工具欄
- Framework7 - 搜尋欄
- Framework7 - 狀態列
- Framework7 - 側邊面板
- Framework7 - 內容塊
- Framework7 - 佈局網格
- Framework7 - 覆蓋層
- Framework7 - 預載入器
- Framework7 - 進度條
- Framework7 - 列表檢視
- Framework7 - 手風琴
- Framework7 - 卡片
- Framework7 - 晶片
- Framework7 - 按鈕
- Framework7 - 操作按鈕
- Framework7 - 表單
- Framework7 - 標籤頁
- Framework7 - Swiper 滑塊
- Framework7 - 圖片瀏覽器
- Framework7 - 自動完成
- Framework7 - 選擇器
- Framework7 - 日曆
- Framework7 - 重新整理
- Framework7 - 無限滾動
- Framework7 - 訊息
- Framework7 - 訊息欄
- Framework7 - 通知
- Framework7 - 懶載入
- Framework7 樣式
- Framework7 - 顏色主題
- Framework7 - 分割線
- Framework7 模板
- Framework7 - 模板概述
- Framework7 - 自動編譯
- Framework7 - Template7 頁面
- Framework7 快速點選
- Framework7 - 活動狀態
- Framework7 - 長按事件
- Framework7 - 觸控漣漪
- Framework7 有用資源
- Framework7 - 快速指南
- Framework7 - 有用資源
- Framework7 - 討論
Framework7 - 示例材料
描述
Framework7 通知也可以用於 Material 佈局。
示例
以下示例演示了在 Framework7 中使用 Material 佈局通知的方法:
<!DOCTYPE html>
<html class="with-statusbar-overlay">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<title>Notifications</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/css/framework7.material.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/css/framework7.material.colors.min.css">
</head>
<body>
<div class="views">
<div class="view view-main">
<div class="pages navbar-fixed">
<div data-page="home" class="page">
<div class="navbar">
<div class="navbar-inner">
<div class="center">Notifications</div>
</div>
</div>
<div class="page-content">
<div class="content-block">
<p><a href="#" class="button button-raised notification-single">Single-line notification</a></p>
<p><a href="#" class="button button-raised notification-multi">Multi-line notification</a></p>
<p><a href="#" class="button button-raised notification-custom">With custom button</a></p>
<p><a href="#" class="button button-raised notification-callback">With callback on close</a></p>
</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/js/framework7.min.js"></script>
<script>
var myApp = new Framework7({
material: true
});
var mainView = myApp.addView('.view-main');
var $$ = Dom7;
$$('.notification-single').on('click', function () {
myApp.addNotification({
message: 'Battery remaining only 20%'
});
});
$$('.notification-multi').on('click', function () {
myApp.addNotification({
message: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
});
});
$$('.notification-custom').on('click', function () {
myApp.addNotification({
message: 'Nice teal color button',
button: {
text: 'Click me',
color: 'teal'
}
});
});
$$('.notification-callback').on('click', function () {
myApp.addNotification({
message: 'Close this notification to see an alert',
button: {
text: 'Close Me',
color: 'red'
},
onClose: function () {
myApp.alert('Callback made.. Notification closed');
}
});
});
</script>
</body>
</html>
輸出
讓我們執行以下步驟來檢視上面給出的程式碼是如何工作的:
將上面給出的 HTML 程式碼儲存為 **notifications_material.html** 檔案,放在伺服器根目錄下。
以 https:///notifications_material.html 的方式開啟此 HTML 檔案,輸出結果將如下所示。
此示例提供了不同型別的通知,例如單行通知、多行通知、帶有自定義按鈕的通知等,均在 Material 佈局中。
framework7_notifications.htm
廣告