聯(lián)系官方銷售客服
1835022288
028-61286886
請問小程序中的點(diǎn)贊數(shù)字為啥不能正常顯示?
插件名稱:小程序DEMO
我復(fù)制過來的show.js
調(diào)用的時(shí)候也是{{supports}}
但是不懂為什么,默認(rèn)加載的時(shí)候,數(shù)據(jù)都顯示為0,不會顯示正確的點(diǎn)贊數(shù),只有點(diǎn)擊了這個(gè)按鈕,增加或者減少了點(diǎn)贊次數(shù),這個(gè)點(diǎn)贊次數(shù)才會正確。
是自定義回調(diào)那邊沒輸出好嗎?自定義回調(diào)那邊沒寫,我看了下JSON數(shù)據(jù),點(diǎn)贊數(shù)是NULL
show.wxml
<view class="l_lbdz l_lbliuc fl" bindtap="up"> <view class="l_lbliu l_lbliub"> <image mode="widthFix" src="{{upsImg}}"></image> </view> <view class="l_lbliubc">{{supports}}</view> </view>
show.js
var WxParse = require('../../wxParse/wxParse.js'); var app = getApp(); var http_url = app.globalData.http_api + "s=anli&c=show"; http_url += '&api_call_function=anli_show_data'; var member_url = app.globalData.http_api + "s=api&app=anli&c=module&api_auth_code=" + wx.getStorageSync('member_auth') + "&api_auth_uid=" + wx.getStorageSync('member_uid'); Page({ data: { id: '', content: '', supports: 0, upsImg: "../../images/xqb.png", collectImg: "../../icons/collect.png", }, onLoad: function (options) { app.showModel(); var self = this; wx.request({ url: http_url, data: { id: options.id }, header: { 'content-type': 'application/json' }, dataType: 'json', method: 'GET', success: function (res) { if (res.data.code == 1) { // 是否收藏 wx.request({ url: member_url + '&m=is_favorite', data: { id: options.id }, header: { 'content-type': 'application/json' }, dataType: 'json', method: 'GET', success: function (sc) { if (sc.data.code == 1) { self.setData( { collectImg: "../../icons/collect-active.png", }) } } }); // 格式化文章內(nèi)容 var article = res.data.data.content; WxParse.wxParse('data', 'html', article, self); self.setData({ content: res.data.data, supports: res.data.data.support, id: options.id }) wx.hideToast(); } else { wx.showModal({ showCancel: false, content: res.data.msg }) } } }) }, up: function () {//點(diǎn)贊 var self = this; wx.request({ url: member_url + '&m=digg&value=1', data: { id: self.data.id }, header: { 'content-type': 'application/json' }, dataType: 'json', method: 'GET', success: function (sc) { if (sc.data.code == 1) { wx.showToast({ icon: 'success', title: sc.data.msg, duration: 2000 }); self.setData( { supports: sc.data.data, }) } else { wx.showModal({ showCancel: false, content: sc.data.msg }) } } }); } })
后臺自定義回調(diào)
直接訪問API,得到了NULL空值
如何排查問題
1、通過接口訪問,(去掉回調(diào)函數(shù)參數(shù))試試變量是否出了,如果不出來說明數(shù)據(jù)庫無這個(gè)字段
2、通過接口訪問,(加上回調(diào)函數(shù)參數(shù))試試變量是否出了,如果不出來說明回調(diào)函數(shù)寫法有問題