页面部分
<view class="toast" v-show="toastBool">
{{toastText}}
</view>
js部分
toastText.value = '兑换码不存在';
toastBool.value = true;
hideToast();
//关闭提示框
function hideToast() {
setTimeout(function() {
toastBool.value = false;
}, 2000)
};
css部分
.toast {
width:fit-content;
position: fixed;
padding: 30rpx;
color: #fff;
background: rgba(0, 0, 0, .7);
font-size: 28rpx;
border-radius: 10rpx;
left: 50%;
z-index: 999;
top: 50%;
transform: translate(-50%, -50%);
}