Javascript 我在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) 我以前用过“this”,但除了今天,我没有得到那个错误。 这是我的密码Javascript 我在vuejs中有一个错误,javascript,vue.js,vuejs2,vue-component,vue-router,Javascript,Vue.js,Vuejs2,Vue Component,Vue Router,我正在使用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
<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>
导出默认值{
名称:'客户',
数据(){
返回{
顾客:[]
}
},
方法:{
吸引顾客({
这是。$http.get('http://slimapp/api/customers')
.然后(功能(响应){
this.customers=JSON.parse(response.body);
});
})
},
已创建:函数(){
这是fetchCustomers();
}
}
求你了!!帮助您的语法错误。它必须是
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>
导出默认值{
名称:'客户',
数据(){
返回{
顾客:[]
}
},
方法:{
获取客户(){
这是。$http.get('http://slimapp/api/customers')
.然后(功能(响应){
this.customers=JSON.parse(response.body);
});
}
},
已创建:函数(){
这是fetchCustomers();
}
}
OHH!!非常感谢,我不在乎。