Ruby on rails 4 轨道4+;Vue:组件未显示

Ruby on rails 4 轨道4+;Vue:组件未显示,ruby-on-rails-4,vue.js,Ruby On Rails 4,Vue.js,我有一个简单的看法: <div id="purchases"> <table> <thead> <tr> <th>Name</th> <th>Email</th> <th>Manager</th> </tr> </thead> <tbody>

我有一个简单的看法:

<div id="purchases">
  <table>
    <thead>
      <tr>
        <th>Name</th>
        <th>Email</th>
        <th>Manager</th>
      </tr>
    </thead>
    <tbody>
      <tr v-for="purchase in purchases">
        <td>{{ purchase.created_at }}</td>
        <td>{{ purchase.weeks }}</td>
        <td>{{ purchase.weekly_cost }}</td>
      </tr>
    </tbody>
  </table>
</div>

…但是视图中没有加载数据,当我查看devtools中的network选项卡时,从未进行过ajax调用为什么会发生这种情况?

您是在尝试使用Vue 1还是2?因为ready lifecycle hook已被弃用,所以您使用的是VueJS 2.0。请使用
挂载的
-\u-谢谢。这就解决了问题。显然我的教程已经过时了
$(document).ready(function() {
  var purchases = new Vue({
    el: '#purchases',
    data: {
      purchases: []
    },
    ready: function() {
      var that;
      that = this;
      $.ajax({
        url: '/purchases.json',
        success: function(res) {
          console.log(res)
          that.purchases = res;
        }
      });
    }
  });
});