반응형
유형 스크립트가 포함된 Vue 플러그인이 null의 속성 '_init'을 읽을 수 없습니다.
재사용 가능한 몇 가지 구성 요소가 포함된 Vue 플러그인을 생성해야 합니다.TypeScript를 사용하여 만들고 싶습니다.내 파일이 있습니다.
컴포넌트/SampleButton을 선택합니다.표시하다
<template>
<button>Sample button</button>
</template>
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
name: 'sample-button',
});
</script>
메인
import SampleButton from './components/SampleButton.vue';
export {
SampleButton,
};
export default {
install(Vue: any, _options: object = {}): void {
Vue.component(SampleButton.name, SampleButton);
},
};
shims-vue.d.ts
declare module '*.vue' {
import Vue from 'vue';
export default Vue;
}
플러그인 구축은 성공했지만 앱에서 플러그인을 사용하려고 하면 다음과 같은 오류가 나타납니다.
import MyPlugin from 'my-plugin'
Vue.use(MyPlugin)
실수를 찾을 수 있도록 도와주세요:)
언급URL : https://stackoverflow.com/questions/58980982/vue-plugin-with-typescript-cannot-read-property-init-of-null
반응형
'programing' 카테고리의 다른 글
Eslint 상태가 이미 선언된 [Vuex] (0) | 2022.07.04 |
---|---|
Vue Jest 테스트에서 navigato.geolocation.getCurrentposition을 "mock"하는 방법 (0) | 2022.07.04 |
C의 불투명 포인터는 무엇입니까? (0) | 2022.07.03 |
Vue JS의 계산된 필터에서 여러 값을 반환합니다. (0) | 2022.07.03 |
Vue, $가 무슨 뜻이지? (0) | 2022.07.03 |