如下源码会导致 v-show 失效:
<template>
<view>
<view class="dialog_nav" :style="'top:' + navH + 'rpx;'" v-show="currentPage">
<text>内容</text>
</view>
</view>
</template>
<script>
export default {
data() {
return {
navH: 100,
currentPage: false
};
}
};
</script>
如下代码符合预期:
<template>
<view>
<view class="dialog_nav" :style="{ top: `${navH}rpx` }" v-show="currentPage">
<text>内容</text>
</view>
</view>
</template>
<script>
export default {
data() {
return {
navH: 100,
currentPage: false
};
}
};
</script>
0 个回复