1
我試圖通過計算正確的寬度和高度作爲一個屬性,並在一個屬性鐵圖像。這適用於Chrome和Firefox,但不適用於Safari。聚合物鐵圖像動態大小不適用於Safari
<dom-module id="x-example">
<style>
:host {
display: block;
}
</style>
<template>
<div>
image sizes should be {{imgWidth}} x {{imgWidth}}px
</div>
<iron-image src="http://lorempixel.com/200/200/" style="width: {{imgWidth}}px; height:{{imgWidth}}px" sizing="cover" preload fade></iron-image>
<iron-image src="http://lorempixel.com/400/200/" style="width: {{imgWidth}}px; height:{{imgWidth}}px" sizing="cover" preload fade></iron-image>
<iron-image src="http://lorempixel.com/400/200/" style="width: {{imgWidth}}px; height:{{imgWidth}}px" sizing="cover" preload fade></iron-image>
</template>
</dom-module>
addEventListener('WebComponentsReady', function() {
Polymer({
is: 'x-example',
properties: {
imgWidth: {
type: Number,
value: function() {
return Math.round(window.innerWidth/2);
}
},
}
});
});
任何想法,爲什麼這並不Safari瀏覽器(臺式機或移動設備)上運行?圖像根本不顯示。
哎,完全忘記了屬性綁定。事實上,它在Chrome/FF中工作(爲什麼會這樣?)讓我覺得我並沒有錯過一些根本性的東西。非常感謝! –
@RonanCremin沒問題:) – tony19