【发布时间】:2021-10-02 02:39:17
【问题描述】:
我想像下面这样声明一个类
class Customer{
constructor(){
this.id;
this.name;
this.email;
this.username;
this.password;
}
}
我想像这样在 vuejs 中的任何组件中创建它的实例
export default {
name: 'TestCompotent',
data()
{
return{
MainCutomer: new Customer()
}
},
}
请给我建议,我该怎么做?
【问题讨论】:
-
没有在每个组件中导入?
-
只需导入类似于上面导出默认值的类 -
import MainCustomer from./path/Customer.js`
标签: vue.js vue-component vuex vue-router