3
我想导入一个助手类而不是内联组件内部的逻辑。我得到以下错误:Vue组件中的导入助手类
http://eslint.org/docs/rules/no-unused-vars 'NavbarService' is defined but never used
/services/NavbarService.js
class NavbarService {
constructor (init) {
this.init = init;
}
static applications() {
return [
{ name: 'Administration' },
{ name: 'Standard' }
];
}
static views() {
return [
{ name: 'Providers', path: '/providers' },
{ name: 'Authorities', path: '/authorities' },
{ name: 'Services', path: '/services' },
{ name: 'Codes', path: '/codes' }
];
}
}
/components/Navbar.vue
import NavbarService from '../services/NavbarService.js';
export default {
data() {
return {
versionIsVisible: false,
version: '2.0.0',
applications: NavbarService.applications(),
views: NavbarService.views()
};
},
methods: {
showApplications: function() {
this.applications = NavbarService.applications();
this.views = [];
return;
}
}
};
做任何事情不断实例化类,或者是纯粹为辅助功能的容器? –
纯粹是一个容器。 – Donnie
我想你不想上课。你能把它变成一个普通的物体吗? –