|
[App引擎]
stml页面动态显示或隐藏元素?
[复制链接]
大家好,
我想实现功能:
未登录时loginOk为false, 这时显示 登录
已登录时loginOk为true, 这时显示 退出登录
但现在总是显示登录(loginOk为true时也显示 登录), 请问代码是哪里有问题啊?
<template>
<view class="page" onclick="api.closeFrame();">
<view v-show="!loginOk">
<cell class="cell" @click="openInMain('mLogin.aspx')" style={tapStyles.circle}
ontouchstart="touch('circle')" ontouchend="untouch('circle')" ontouchcancel="untouch('circle')">
<image src="../../image/login.png" class="my-icon" mode="aspectFit"/>
<text class="title">登录</text>
</cell>
</view>
<view v-show="loginOk">
<cell class="cell" @click="openInMain('mLogout.aspx')" style={tapStyles.circle}
ontouchstart="touch('circle')" ontouchend="untouch('circle')" ontouchcancel="untouch('circle')">
<image src="../../image/logout.png" class="my-icon" mode="aspectFit"/>
<text class="title">退出登录</text>
</cell>
</view>
</view>
</template>
<script>
import '../../script/api.js';
import '../../script/315.js';
export default {
name: 'shareMenu',
data() {
return {
tapColor: '#cccccc',
tapStyle: '',
tapStyles: {
circle: '',
weixin: '',
more: ''
},
loginOk: false
}
},
apiready() {//like created
var uPref = api.getPrefs({ key: 'cookie315', sync: true });
var u;
if (uPref) {
u = $api.strToJson(uPref);
} else {
u = {};
}
if (u.id > 0) {
console.debug('已登录' + $api.jsonToStr(u));
loginOk = true;
}
else
{
console.debug('未登录' + $api.jsonToStr(u));
loginOk = false;
}
},
methods: {
......
</script>
<style>
...
</style>
|
|