【发布时间】:2016-11-16 17:36:58
【问题描述】:
我希望铁媒体查询在查询匹配发生变化时调用一个函数并检查查询匹配是否为真,做点什么...
这是我的代码:
<dom-module id="example-example">
<style>
</style>
<template>
<iron-media-query query="(min-width: 200px)" query-matches="{{small}}" on-query-matches-changed="detectSmall"></iron-media-query>
<iron-media-query query="(min-width: 1400px)" query-matches="{{large}}" on-query-matches-changed="detectLarge"></iron-media-query>
</template>
<script>
Polymer({
is: 'example-example',
detectLarge: function(){
console.log(this.large);
},
detectSmall: function(){
console.log(this.small);
}
});
</script>
</dom-module>
我第一次加载页面时,我的设备宽度是 1300px 所以 this.small 应该是 true ,但它是未定义的。
我到底做错了什么?
【问题讨论】:
标签: polymer polymer-1.0