<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                [TOC] ``` ## //獲取組件中的傳值 onLike(e) { var behavior = e.detail.behavior; var id = this.data.classic.id; var type = this.data.classic.type; likeModel.getLike(behavior, id, type); } ``` ## 獲取更新數據 ``` _updateData(nextOrprevious) { /* 調用models里的獲取 緩存或發送http */ classicModel.getClassic(this.data.classic.index, nextOrprevious, res => { /* 更新點贊的狀態 */ likeModel.getLikeStatus(res.type,res.id,res=>{ this.setData({ like:res.like_status, count:res.fav_nums }) }) }) } ``` ## models/like.js ``` //HTTP請求(在5.HTTP的封裝里) import {HTTP} from "../utils/http"; class LikeModel extends HTTP { getLike(behavior,id,type){ const url = behavior?'/like':'/like/cancel' this.request({ url, method:"POST", data:{ art_id:id, type } }) } /* 獲取 期刊 點贊的信息 */ getLikeStatus(type,id,callback){ this.request({ url:`/classic/${type}/${id}/favor`, success: res =>{ callback(res) } }) } } export {LikeModel} ``` ## like組件 ``` methods: { onLike(){ var like = this.properties.like; var count = this.properties.count; if(like){ this.setData({ like:false, count:count-1 }) }else{ this.setData({ like:true, count:count+1 }) } //向父組件傳值 var behavior = this.data.like; this.triggerEvent('like',{ behavior }) } } ``` ## wxml ``` <view class="like"> <image src="{{like?yesSrc:noSrc}}" alt="" bind:tap="onLike" ></image> <text class="count">{{count}}</text> </view> ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看