通用事件&样式

此处有通用事件的描述
此处是通用样式的描述

  1. <text id="text1" class='txt'
  2. @click="onclick"
  3. @longpress="onlongpress"
  4. @appear="onappear"
  5. @disappear="ondisappear">{{content}}
  6. </text>
  7. <!--
  8. 通用事件中一般event都默认有三个属性
  9. 1、type: 事件名字,如 click
  10. 2、target : 触发事件的组件对象
  11. 3、timestamp : 事件被触发时的时间戳
  12. 4、direction : 触发事件时屏幕的滚动方向,up 或 down -- 在appear和disappear放在可滚动的容器中才有
  13. <input> 和 <switch> 组件目前不支持 click,longpress 事件,用 change 或 input 事件来代替。
  14. -->

文本在android中居中

如果有设置文本组件的高度,则需要填加上line-height与之匹配,否则会靠上显示

.txt {
    text-align: center;
    line-height: 300px; -- 此属性和height匹配
    height: 300px;
    font-size: 60px;
    color: red;
    border-radius: 20px;
    border-color: blue;
    border-style: dotted;
    border-width: 2px;
    margin: 12px;
    background-color: aqua;
}

组件&style - 图2

<image id="img" class="img"
       resize="stretch"
       src="https://gw.alicdn.com/tfs/TB1dZ4WowoQMeJjy0FnXXb8gFXa-950-1267.jpg"></image>
.img {
        height: 300px;
        width: 300px;
        /*如果有设置宽高度,但是view自己宽高未铺满父布局,则可以通过align-self来指定位置*/
        align-self: center;
    }