国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

vue+php實(shí)現(xiàn)的微博留言功能示例

2024-05-06 15:41:38
字體:
供稿:網(wǎng)友

本文實(shí)例講述了vue+php實(shí)現(xiàn)的微博留言功能。分享給大家供大家參考,具體如下:

html部分:

<!doctype html><html><head><meta charset="utf-8"><title>微博留言</title><link href="style/weibo.css" rel="external nofollow" rel="stylesheet" type="text/css" /><script src="https://cdn.bootcss.com/vue/2.4.4/vue.min.js"></script><script src="https://cdn.bootcss.com/vue-resource/1.5.0/vue-resource.js"></script>  <style>    [v-cloak]{      display: none;    }  </style>  <script>    Vue.filter('formatDate',function (date) {      var oData = new Date(date*1000)      return oData.getFullYear()+'-'+(oData.getMonth()+1)+'-'+oData.getDate()+" "+ oData.getHours()+":"+oData.getMinutes()+":"+oData.getSeconds()    });    window.onload = function () {      var vm = new Vue({        el:'.znsArea',        data:{          userMsg:'',          msgDict:[],          url:'weibo.php',          totalPage :0,          nowpage:1        },        methods:{          add:function () {            if(this.userMsg=='') return            this.$http.get(this.url, {              params:{                'act':'add',                'content':this.userMsg              }            }).then(function (res) {              this.msgDict.unshift({                'content':this.userMsg,                'time':res.data.time,                'acc':0,                'ref':0,                'id':res.data.id              })              this.userMsg = ''            })          },          loadData:function (n) {            this.$http.get(this.url,{              params:{                'act':'get',                'page':n              }            }).then(function (res) {              this.msgDict = res.data            })          },          pageCount:function () {            this.$http.get(this.url,{              params:{                'act':'get_page_count'              }            }).then(function (res) {              this.totalPage = res.data.count            })          },          changePage:function (i) {            this.nowpage=i            this.loadData(i)          },          del:function (did) {            this.$http.get(this.url,{              params:{                act:'del',                id:did              }            }).then(function () {              for(var delitem in this.msgDict){                if(this.msgDict[delitem].id==did){                  this.msgDict.splice(this.msgDict[delitem],1)                }              }            })            this.loadData(this.nowpage)          },          acc:function (mid) {            this.$http.get(this.url,{              params:{                act:'acc',                id:mid              }            }).then(function () {              for(var item in this.msgDict){                if(this.msgDict[item].id==mid){                  this.msgDict[item].acc +=1                }              }            })          },          ref:function (mid) {            this.$http.get(this.url,{              params:{                act:'ref',                id:mid              }            }).then(function () {              for(var item in this.msgDict){                if(this.msgDict[item].id==mid){                  this.msgDict[item].ref +=1                }              }            })          }        },        created:function () {          this.loadData(1)          this.pageCount()        }      })    }  </script></head><body><div class="znsArea"><!--留言-->   <div class="takeComment">    <textarea name="textarea" class="takeTextField" id="tijiaoText" v-model="userMsg" @keydown.enter="add"></textarea>    <div class="takeSbmComment">      <input type="button" class="inputs" value="" @click="add" @keydown.enter="add"/>      <span>(可按 Enter 回復(fù))</span>    </div>  </div><!--已留-->  <div class="commentOn">    <div class="noContent" v-show="msgDict.length==0">暫無留言</div>    <div class="messList">      <div class="reply" v-for="item in msgDict">        <p class="replyContent" v-text="item.content"></p>        <p class="operation">          <span class="replyTime" v-cloak>{{item.time|formatDate}}</span>          <span class="handle">            <a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="top" v-text="item.acc" @click="acc(item.id)"></a>            <a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="down_icon" v-text="item.ref" @click="ref(item.id)"></a>            <a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="cut" @click="del(item.id)">刪除</a>          </span>        </p>      </div>    </div>    <div class="page">      <span v-for="i in totalPage">        <a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" @click="changePage(i)" v-text="i" :class="{active:i==nowpage}"></a>      </span>    </div>  </div></div></body></html>            
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 涪陵区| 满城县| 开原市| 河曲县| 体育| 巧家县| 昂仁县| 凤台县| 靖安县| 绍兴市| 开封市| 米林县| 涡阳县| 龙门县| 梓潼县| 乐山市| 镇康县| 开平市| 厦门市| 同江市| 凉山| 东乡| 宁南县| 久治县| 当阳市| 英超| 太谷县| 龙山县| 都安| 涡阳县| 长海县| 太湖县| 远安县| 霍州市| 万荣县| 江油市| 麻阳| 海宁市| 灌南县| 和硕县| 梅州市|