我想,当设备屏幕大小重新安排布局,所以我这样做:
if(screenOrientation == SCREEN_ORIENTATION_LANDSCAPE) {
document.querySelector("html /deep/ [landscape-horizontal]").removeAttribute('vertical');
document.querySelector("html /deep/ [landscape-horizontal]").setAttribute('horizontal', '');
}
这是工作在台式机上正确,但在手机(包括Android手机,平板电脑和iOS模拟器)我得到这个错误:
"Uncaught SyntaxError: Failed to execute 'webkitMatchesSelector' on 'Element': 'html /deep/ [landscape-horizontal]' is not a valid selector.", source: bower_components/platform/platform.js (0)
有任何想法吗? 谢谢!
公司目前旗下有一个悬而未决的问题 ,以支持这一阴影DOM填充工具。 它适用于Chrome 35+,因为这是使用原生的影子DOM。
我通过CSS解决了这个问题:
<style shim-shadowdom>
body[portrait] /deep/ [layout][horizontal][landscape], body[landscape] /deep/ [layout][horizontal][portrait] {
-ms-flex-direction: column;
-webkit-flex-direction: column;
flex-direction: column;
}
body[portrait] /deep/ [layout][vertical][landscape], body[landscape] /deep/ [layout][vertical][portrait] {
-ms-flex-direction: row;
-webkit-flex-direction: row;
flex-direction: row;
}
</style>
现在我变“风景”和“肖像”身体属性屏幕大小的变化。 这是工作在所有浏览器。
随着平台版本≥0.4.0您现在可以使用/deep/
组合子毫不畏惧,它已经polyfilled的非本地浏览器。
document.querySelector('html /deep/ [landscape-horizontal]');