【问题标题】:this.$set() is not working in vue2.0 with laravelthis.$set() 在带有 laravel 的 vue2.0 中不起作用
【发布时间】:2017-02-15 04:21:04
【问题描述】:

我正在尝试在 vue js 中设置一些数据并在视图中访问它们。

我的vue方法,

getVueItems: function(){
        var vm = this;
        axios.get('/someuri').then(function(response)  {
        vm.$set(this,'items', response.data);
      });
    },

在我看来,

<tr v-for="item in items">
        <td>@{{ item.id }}</td>
        <td>@{{ item.name }}</td>
</tr>

路由正在返回结果,但无法将其设置为items,然后在视图中循环它们。

我是不是做错了什么。有什么解决方法吗?

【问题讨论】:

    标签: php laravel vue.js vuejs2


    【解决方案1】:

    利用自动绑定 this 的 es2015 语法...

    getVueItems: function(){
            axios.get('/someuri').then(response => {
            this.items = response.data;
          });
        },
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-13
      • 2022-08-19
      • 1970-01-01
      • 2018-08-16
      • 1970-01-01
      • 1970-01-01
      • 2017-05-08
      • 1970-01-01
      相关资源
      最近更新 更多