支援
Framework7 也附有功能偵測函式庫。
它可用作 Framework7 類別(Framework7.support
)的 support
屬性,以及初始化的應用程式實例(app.support
)上的相同屬性
// If we need it in place where we don't have access to app instance or before we init the app
if (!Framework7.support.touch) {
console.log('No touch support');
}
// After we init the app we can access it as app instance property
var app = new Framework7({ /*...*/ });
if (!app.support.touch) {
console.log('No touch support');
}
getSupport
當我們將 Framework7 與 ES 模組搭配使用時,我們需要改用 getSupport
工具
import { getSupport } from 'framework7';
const support = getSupport();
if (!support.touch) {
console.log('No touch support');
}
支援屬性
觸控 | 觸控事件支援(touchstart、touchmove、touchend) |
指標事件 | 指標事件支援 |
交集觀察器 | 交集觀察器支援 |
被動監聽器 | 被動事件監聽器支援 |