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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
| <template> <view class="content f f-wrap"> <image class="logo" src="../../static/image/myHover.png" @click="tap" ></image>
<view :class="{ active: isActive }">111</view>
<view class="static" :class="{ active: isActive, 'text-danger': hasError }"> 222 </view>
<view class="static" :class="[activeClass, errorClass]">333</view>
<view class="static" v-bind:class="[isActive ? activeClass : '', errorClass]" > 444 </view>
<view class="static" v-bind:class="[{ activeGrey: isActive }, errorClass]"> 555 </view>
<view class="container" :class="computedClassStr"></view> <view class="container" :class="{activeGrey: isActive}">9999</view>
<view v-bind:style="{ color: activeColor, fontSize: fontSize + 'px' }"> 666 </view> <view v-bind:style="[{ color: activeColor, fontSize: fontSize + 'px' }]"> 777 </view> </view> </template>
<script> export default { data() { return { title: 'Hello',
isActive: true, hasError: true,
activeClass: { active: false, 'text-danger': true }, errorClass: { active: true, 'text-danger': false },
activeColor: true, fontSize: 30 }; }, onLoad() { this.fetchData(); console.log('页面加载'); }, onShow() { console.log('页面显示'); }, onReady() { console.log('页面初次显示'); }, onHide() { console.log('页面隐藏'); }, onUnload() { console.log('页面卸载'); }, onBackPress() { console.log('页面返回...'); }, onShareAppMessage() { console.log('分享!'); }, onReachBottom() { console.log('下拉加载...'); }, onPageScroll() { console.log('页面滚动...'); }, onPullDownRefresh() { console.log('上拉刷新...'); uni.stopPullDownRefresh(); },
onNavigationBarButtonTap() {},
methods: { tap(e) { console.log('tap点击!', e); }, fetchData() { console.log('拉取数据...'); }, computedClassStr() { return this.isActive ? 'actives' : 'active'; } } }; </script>
<style lang="scss"> .active { color: #f00; }
.activeGrey { color: #aaa; }
.text-danger { color: #f0f; font-weight: bold; }
.f { display: flex; }
.f-wrap { flex-wrap: wrap; } </style>
|