可直接判断在app中和在小程序中显示的不同效果
<!-- #ifdef APP-PLUS -->
<image class="logo" src="../../static/img/app.png" mode="widthFix" style="width: 100%;"></image>
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<image class="logo" src="../../static/img/wx.png" mode="widthFix" ></image>
页面源码:
<template>
<view class="content">
<!-- #ifdef APP-PLUS -->
<image class="logo" src="../../static/img/app.png" mode="widthFix" style="width: 100%;"></image>
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<image class="logo" src="../../static/img/wx.png" mode="widthFix" ></image>
<!-- #endif -->
<view class="text-area">
<text class="title" style="color: #007AFF;">{{name}}--{{age}}</text>
</view>
<view>{{studentArr[0].name}}</view>
<view v-for="(arr,index) in studentArr">{{arr.name}}</view>
<view v-if="flag">v-if</view>
<view :hidden="hiddenFlag">hidden</view>
<!-- <button type="warn">button</button> -->
</view>
</template>
<script>
import add from '../../static/js/bootstrap-vue.min.js'
var $this = '';
export default {
data() {
return {
flag : true,
hiddenFlag :true,
name: 'cth',
age:'23',
studentArr:[
{name : "cth", age : '23'},
{name : "jcc", age : '22'},
]
}
},
onLoad() {
$this = this;
setTimeout(function(){
// console.log($this.age);
$this.age++;
},2000)
// console.log('index页面刷新')
},
//当 uni-app 启动,或从后台进入前台显示
onShow() {
// console.log('index页面启动')
},
//隐藏
onHide() {
console.log('index页面隐藏')
},
onError() {
console.log('index 页面error')
},
methods: {
}
}
</script>
<style>
/* @import url("../../static/css/bootstrap.css"); */
/* @import url("../../static/css/bootstrap-vue.min.css"); */
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>
效果图: