Vue.js 通过jQuery ajax获取数据实现更新后重新渲染页面的方法
1. 引入jquery和vue.js
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> <script type="text/javascript" src="http://cdn.bootcss.com/vue/2.2.2/vue.min.js"></script>
2. JS
<script type="text/javascript"> $(function(){ vm = new Vue({ el:'#lst', data:{ mcs : [] } }); getmc(); }); function getmc(){ $.get("getJsonData.action", function(msg){ vm.mcs = msg }); } </script>
3. HTML
<div id="lst" v-cloak> <div v-for="mc in mcs"> <p> <a :href="'abbbbb.action?id=' + mc.id " rel="external nofollow" >{{mc.titles}}</a> </p> </div> </div><p> <input type="button" onclick="getmc()" value="更新页面" /> </p>
相关推荐
TONIYH 2020-07-22
83510998 2020-07-18
wcqwcq 2020-06-26
delmarks 2020-06-14
ppsurcao 2020-06-14
tthappyer 2020-06-07
EdwardSiCong 2020-11-23
85477104 2020-11-17
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
momode 2020-09-11
85477104 2020-08-15
83510998 2020-08-08