0
私のxmlのbottle
ビュー/要素のレンダリングされた高さを取得するネイティブスクリプトアプリケーションを作成しようとしています。私は次のコードを試しましたが、残念ながらエラーが発生します(下記参照)。どんな指導も大歓迎です。NativeScriptで要素の高さにアクセスする
JS:
var viewModule = require("ui/core/view");
var page;
exports.fabTap = function (args) {
page = args.object;
var bottle = page.getViewById("bottle");
console.log("Height: " + bottle.height);
}
XML:
<Page xmlns="http://schemas.nativescript.org/tns.xsd" xmlns:FAB="nativescript-floatingactionbutton" actionBarHidden="true" loaded="pageLoaded">
<GridLayout columns="*, *, *, *" rows="15*, 5*, 20*, 5*, 5*, 5*, 5*, 20*, 20*" width="100%" height="100%" style.backgroundColor="white" >
<Image src="res://logo" row="0" col="1" colSpan="2" stretch ="aspectFit" class="logo"/>
<Image id="bottle" src="res://bottle_outline" row="2" col="0" rowSpan="6" colSpan="2" stretch="aspectFit"/>
</GridLayout>
</Page>
が未定義のプロパティ '高さ' を読み込めません。
おかげで、問題。しかし、私は今、 'Height:NaN'をログに出力します、なぜこれがありますか? –
@GeorgeEdwardsプロパティを設定して実際の値を返さない場合にのみ 'height'が返されます。 'bottle.getMeasuredHeight()'を印刷して、違いがあるかどうか確認してください。 –