vue.js和jquery的ajax结合

jsp页面:

<div id="app">
    {{message }}<br>
    <button v-on:click="showData">测试jquery加载数据</button>
    <table border="1">
      <tr v-for="data in datas">
        <td>{{data.Name}}</td>
        <td>{{data.Url}}</td>
        <td>{{data.Country}}</td>
      </tr>
    </table>
  </div>

js代码:

//定义Vue组件
var vum=new Vue({
  el: "#app",
  data: {
    message: "",
    datas: "",
 
  },
  methods:{
    showData:function () {
      jQuery.ajax({
        type: 'Get',
        url: "/vue1/json/data.json",
        success: function (data) {
          vum.datas = data.sites;
        }
      })
    }
  }
})

猜你喜欢

转载自blog.csdn.net/weixin_42412462/article/details/81745891