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' :style="show ? '' : 'display:none;'" @click="getCode">發送</button>
5 <button class='cu-btn line-grey shadow' :style="!show ? '' : 'display:none;'">{{count}}s</button>
6 </view>

使用:class也是一樣的效果,還有在uni-app中,request請求傳的參數格式不對時在請求頭中加入

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

就可以將參數改為josn格式


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM