uni-app编译小程序v-show踩坑,以及uni-app.request请求

本文章向大家介绍uni-app在小程序中v-show指令失效,主要包括uni-app在小程序中v-show指令失效使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

因为公司需要,使用了uni-app一套代码开发微信公众号和微信小程序

遇到了一些bug

比如v-show,在公众号,h5网页当中都可以正常显示,但是编译到小程序中,就不起作用了

说一下我的方法

1 <view class="cu-form-group">
2 <view class="title">验证码</view>
3 <input placeholder="请输入验证码" name="input" v-model="code"></input>
4 <button class='cu-btn bg-green shadow' v-show:="show '" @click="getCode">发送</button>
5 <button class='cu-btn line-grey shadow' v-show:="!show'">{{count}}s</button>
6 </view>

这段代码在公众号是可以的,但是在小程序就有问题,所以将v-show替换成:style

1 <view class="cu-form-group">
2 <view class="title">验证码</view>
3 <input placeholder="请输入验证码" name="input" v-model="code"></input>
4 <button class='cu-btn bg-green shadow' :' : 'display:none;'" @click="getCode">发送</button>
5 <button class='cu-btn line-grey shadow' :' : 'display:none;'">{{count}}s</button>
6 </view>

使用:class也是一样的效果,还有在uni-app中,request请求传的参数格式不对时在请求头中加入

header: {
                    'content-type': 'application/x-www-form-urlencoded', 
                }

就可以将参数改为josn格式