rpx2px.uvue 1.1 KB
Newer Older
H
hdx 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
<template>
  <!-- #ifdef APP -->
  <scroll-view class="page-scroll-view">
  <!-- #endif -->
    <view class="page">
      <page-head :title="title"></page-head>
      <view>
        <view class="item">
          <text class="item-k">输入:</text>
          <text class="item-v">{{rpxValue}}</text>
        </view>
        <view class="item">
          <text class="item-k">返回:</text>
          <text class="item-v">{{pxValue}}px</text>
        </view>
      </view>
      <view>
        <button type="primary" @tap="rpx2px">转换</button>
      </view>
    </view>
  <!-- #ifdef APP -->
  </scroll-view>
  <!-- #endif -->
</template>
<script>
  export default {
    data() {
      return {
        title: 'rpx2px',
        rpxValue: 750,
        pxValue: 0,
        result: false
      }
    },
    methods: {
      rpx2px: function () {
        this.pxValue = uni.rpx2px(this.rpxValue);
      }
    }
  }
</script>

<style>
  .page {
    padding: 15px;
  }

  .item {
    flex-direction: row;
  }

  .item-k {
    width: 72px;
    line-height: 2;
  }

  .item-v {
    font-weight: bold;
    line-height: 2;
  }
</style>