美文网首页
enquire.js 根据 css 媒体查询语句,在 js 中做

enquire.js 根据 css 媒体查询语句,在 js 中做

作者: _十六 | 来源:发表于2021-11-25 09:16 被阅读0次
官网

https://wicky.nillia.ms/enquire.js/#v2.0.0

用法

使用npm安装,其他方式参考官网

npm install enquire.js
import enquire from 'enquire.js'
enquire.register("screen and (max-width:45em)", {

    // OPTIONAL
    // If supplied, triggered when a media query matches.
    match : function() {},

    // OPTIONAL
    // If supplied, triggered when the media query transitions
    // *from a matched state to an unmatched state*.
    unmatch : function() {},

    // OPTIONAL
    // If supplied, triggered once, when the handler is registered.
    setup : function() {},

    // OPTIONAL, defaults to false
    // If set to true, defers execution of the setup function
    // until the first time the media query is matched
    deferSetup : true,

    // OPTIONAL
    // If supplied, triggered when handler is unregistered.
    // Place cleanup code here
    destroy : function() {}

});

相关文章

网友评论

      本文标题:enquire.js 根据 css 媒体查询语句,在 js 中做

      本文链接:https://www.haomeiwen.com/subject/miratrtx.html