我对 vuejs 有错误



我正在使用 vuejs 2 构建一个新应用程序并收到该错误

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

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

<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>

相关内容

最新更新