未使用 Angular2 和 IE 11 设置值(添加垫片)
Value not set with Angular2 and IE 11 (shims added)
首先,让我说,是的,我已经在我的 index.html 中加入了垫片。
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/systemjs/dist/system-polyfills.js"></script>
<script src="node_modules/angular2/es6/dev/src/testing/shims_for_IE.js">
</script>
我正在使用 Angular2 beta-17。
除了IE中的图片样式,下面的字符串属性都解析的很好。
在IE中,名称和地址属性显示正常,但样式是
完全从 img 标签中删除。这在所有其他浏览器中都可以正常工作
Name: {{recipient.name}} <br/>
Address: {{recipient.address}} <br/>
<img style="background: url(/pImages/{{recipient._id}}.jpg);" />
IE 样式值中的括号好像有问题
因为以下硬编码值在 IE
中工作正常
<img style="background: url(/pImages/230721.jpg);" />
我所做的每一次搜索都声称可以通过将
垫片,但我已经做到了。
TIA
这应该适用于所有浏览器:
<img [style.background-image]="'url(/pImages/' + recipient._id + '.jpg)'" />
在 Angular2 版本中 rc.x 您目前需要清理一些样式
见Plunker example and
在测试版中,您不需要我在 Plunker 中使用的管道 (| safe
)。
首先,让我说,是的,我已经在我的 index.html 中加入了垫片。
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/systemjs/dist/system-polyfills.js"></script>
<script src="node_modules/angular2/es6/dev/src/testing/shims_for_IE.js">
</script>
我正在使用 Angular2 beta-17。
除了IE中的图片样式,下面的字符串属性都解析的很好。
在IE中,名称和地址属性显示正常,但样式是 完全从 img 标签中删除。这在所有其他浏览器中都可以正常工作
Name: {{recipient.name}} <br/>
Address: {{recipient.address}} <br/>
<img style="background: url(/pImages/{{recipient._id}}.jpg);" />
IE 样式值中的括号好像有问题 因为以下硬编码值在 IE
中工作正常<img style="background: url(/pImages/230721.jpg);" />
我所做的每一次搜索都声称可以通过将 垫片,但我已经做到了。
TIA
这应该适用于所有浏览器:
<img [style.background-image]="'url(/pImages/' + recipient._id + '.jpg)'" />
在 Angular2 版本中 rc.x 您目前需要清理一些样式
见Plunker example and
在测试版中,您不需要我在 Plunker 中使用的管道 (| safe
)。