반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- localserver
- PYTHON
- 개발
- linux
- Chrome
- 리눅스
- node
- avds
- IOS
- webpack
- react
- picker
- centos
- ReactNative
- 맥
- 네트워크
- xcode
- jest
- build
- androidstudio
- TensorFlow
- VirtualBox
- Android
- MachineLearning
- vsCode
- unittest
- MAC
- qunit
- 센토스
Archives
- Today
- Total
로메오의 블로그
[VUE + TYPESCRIPT] global component 선언하기 본문
반응형
컴포넌트 만들기
/src/component/base/BaseSnackbar.vue
<template>
<div>
snackbar
</div>
</template>
<script lang="ts">
import Vue from 'vue'
import { Component } from 'vue-property-decorator'
@Component
export default class BaseSnackbar extends Vue {}
</script>
Global 콤포넌트 선언
/src/externalModule.ts
import Vue from 'vue'
import BaseSnackbar from '@/components/base/BaseSnackbar.vue'
export function initGlobalComponents () {
Vue.component('BaseSnackbar', BaseSnackbar)
}
/src/main.ts
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import vuetify from './plugins/vuetify'
import { initGlobalComponents } from './externalModule'
Vue.config.productionTip = false
initGlobalComponents()
new Vue({
router,
store,
vuetify,
render: h => h(App)
}).$mount('#app')
사용하기
/src/views/HelloWorld.vue
<template>
<div>
<base-snackbar />
</div>
</template>
<script lang="ts">
import Vue from 'vue'
import { Component } from 'vue-property-decorator'
@Component
export default class HelloWorld extends Vue {
}
</script>
반응형
'Frontend > Vue' 카테고리의 다른 글
[VUE + TYPESCRIPT] 메세지 추가 애니메이션 (0) | 2022.03.25 |
---|---|
[VUE + TYPESCRIPT] proxy server 구현 (0) | 2022.03.24 |
[VUE + TYPESCRIPT] vuetify 설치 + VueDraggableResizable 사용하기 (0) | 2022.03.22 |
[VUE + TYPESCRIPT] unit test - jest (0) | 2022.03.17 |
[VUE + TYPESCRIPT] Life Cycle (0) | 2022.03.15 |
Comments