我有一个非常基本的vue组件:
<script>
export default {
name: "testComponent",
data() {
return {
manageWaiting: new ManageWaiting()
}
}
}
</script>
我尝试像这样用摩卡咖啡对其进行测试:
describe('TestComponent', () => {
it('works', () => {
let wrapper = mount(TestComponent);
});
});
我收到此错误: ReferenceError:未定义ManageWaiting
我应该在哪里导入ManageWaiting类?
答案 0 :(得分:0)
通常,将类定义导入到使用它的同一文件中,因此,在这种情况下,应将ManageWaiting
类导入TestComponent.vue
中:
<script>
// TestComponent.vue
import { ManageWaiting } from './ManageWaiting'
export default {
data() {
return {
manageWaiting: new ManageWaiting()
};
}
}
</script>