- Vue.js 2.x by Example
- Mike Street
- 123字
- 2021-07-02 20:00:32
Resolving JavaScript errors
As with the team-member component, you are going to experience some errors in your JavaScript console. These can be resolved by copying the filter data object and both the changeFilter and isActiveFilterSelected methods from the parent instance. We'll leave them in both the component and parent instance for now, but we'll remove the duplication later:
Vue.component('filtering', {
template: '#filtering-template',
data() {
return {
filter: {
field: '',
query: ''
}
}
},
methods: {
isActiveFilterSelected() {
return (this.filter.field === 'isActive');
},
changeFilter(event) {
this.filter.query = '';
this.filter.field = event.target.value;
}
}
});
Running the app will show both the filters and person listing, but the filters won't update the people list as they are not communicating yet.
推薦閱讀
- Instant Testing with CasperJS
- Mastering JavaScript Functional Programming
- JavaScript前端開發模塊化教程
- Google Apps Script for Beginners
- Oracle Exadata性能優化
- FreeSWITCH 1.6 Cookbook
- SQL for Data Analytics
- Android 9 Development Cookbook(Third Edition)
- Java游戲服務器架構實戰
- SAS數據統計分析與編程實踐
- Python機器學習編程與實戰
- Python Data Analysis Cookbook
- Getting Started with Gulp
- Learning AngularJS for .NET Developers
- INSTANT Yii 1.1 Application Development Starter