我有一个 vuejs 错误

I have an error with vuejs

我正在使用 vuejs 2 构建一个新的应用程序并遇到了这个错误

错误./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0&bustCache!./src/components/Customers.vue 模块构建失败:SyntaxError: C:/Users/Men'm Elkatan/projects/vuecustomers/src/components/Customers.vue: 这是保留字 (17:6)

我以前用过 "this",但今天没有收到预期的错误。 这是我的代码

<script>
export default {
  name: 'customers',
  data () {
    return {
      customers: []
    }
  },
  methods: {
    fetchCustomers({
      this.$http.get('http://slimapp/api/customers')
        .then(function(response) {
          this.customers = JSON.parse(response.body);
        });
    })
  },
  created: function(){
    this.fetchCustomers();
  }
}
</script>

请!!帮助

你的语法有误。必须是 fetchCustomers() { ... }:

<script>
export default {
  name: 'customers',
  data () {
    return {
      customers: []
    }
  },
  methods: {
    fetchCustomers() {
      this.$http.get('http://slimapp/api/customers')
        .then(function(response) {
          this.customers = JSON.parse(response.body);
        });
    }
  },
  created: function(){
    this.fetchCustomers();
  }
}
</script>