欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue.js配合$.post從后臺獲取數(shù)據(jù)簡單demo分享

 更新時間:2018年08月11日 11:27:25   作者:Islandww  
今天小編就為大家?guī)硪黄獀ue.js配合$.post從后臺獲取數(shù)據(jù)簡單demo分享,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧

首先導(dǎo)入

<script type="text/javascript" src="/island/stage/js/vue.min.js"></script>

html樣式:

<div id="main-content" class="wrap-container zerogrid">


<article id="news_content" v-for="item in items">
<div class="col-1-2 right">
<img :src="item.coverimage"/><!--img標簽與src之間需要有空格-->
</div>
<div class="col-1-2 left">
<a class="art-category left" href="#" rel="external nofollow" rel="external nofollow" >{{item.releasetime}}</a>
<div class="clear"></div>
<div class="art-content">
<h2>{{item.title}}</h2>
<div class="info">
<a href="#" rel="external nofollow" rel="external nofollow" >{{item.author}}</a>
</div>
<div class="line"></div>
<p>{{item.content}}</p>
<a v-bind:href="['/island/stage/newscontent.html?id='+item.id]" rel="external nofollow" class="more">閱讀全文</a> <!--屬性數(shù)據(jù)綁定以及拼接-->
</div>
</div>
</article>

<!-- 循環(huán)結(jié)束(新聞) -->
</div>

js部分:

var vm = new Vue({
  el: '#main-content',
  data: {
  items : []
  }, //end data
  created:function(){
  $.post("/island/stage/queryOneAllNews.do",{"categoryid":parseInt(categoryid)},function(data){
  vm.items = data;
  });//end post
  } //created
 }); //end vue

注意:返回的json數(shù)組 并不需要JSON.stringify(data) 轉(zhuǎn)成json字符串 items 這里需要的是json對象

當然 官網(wǎng)上推薦的是使用axios npm這種方式。

以上這篇vue.js配合$.post從后臺獲取數(shù)據(jù)簡單demo就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論