반응형
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 | 31 |
Tags
- MAC
- qunit
- xcode
- TensorFlow
- 리눅스
- jest
- 센토스
- 맥
- webpack
- Android
- node
- build
- react
- vsCode
- localserver
- Chrome
- unittest
- linux
- 티스토리챌린지
- MachineLearning
- centos
- 네트워크
- androidstudio
- 오블완
- 개발
- ReactNative
- VirtualBox
- PYTHON
- IOS
Archives
- Today
- Total
로메오의 블로그
[Vue + typescript] dynamic Component 생성하기 본문
반응형
일반적인 콤포넌트 사용하기
<template>
<div>
<my-component></my-component>
</div>
</template>
<script lang="ts">
import { Vue, Component } from 'vue-property-decorator'
import MyComponent from '@/components/MyComponent.vue'
@Component({
components: {
MyComponent
}
})
export default class DynamicComponent extends Vue {
}
</script>
다이나믹 콤포넌트 사용하기
<template>
<div>
<component :is="isLogined"></component>
</div>
</template>
<script lang="ts">
import { Vue, Component } from 'vue-property-decorator'
import MyComponent from '@/components/MyComponent.vue'
@Component({
components: {
MyComponent
}
})
export default class DynamicComponent extends Vue {
get isLogined () {
if (true) {
return MyComponent
}
}
}
</script>
다이나믹 콤포넌트 상태 보존하기
<template>
<div>
<keep-alive>
<component :is="isLogined"></component>
</keep-alive>
</div>
</template>
<script lang="ts">
import { Vue, Component } from 'vue-property-decorator'
import MyComponent from '@/components/MyComponent.vue'
@Component({
components: {
MyComponent
}
})
export default class DynamicComponent extends Vue {
get isLogined () {
if (true) {
return MyComponent
}
}
}
</script>
다이나믹 콤포넌트 & Transition
<template>
<div>
<button v-on:click="dynamic = !dynamic">
dynamic
</button>
<transition name="dynamic">
<component :is="isDynamic"></component>
</transition>
</div>
</template>
<script lang="ts">
import { Vue } from 'vue-property-decorator'
import TestDynamicChildView from '@/views/test/TestDynamicChildView.vue'
@Component({
components: {
TestDynamicChildView
}
})
export default class TestDynamicComponentView extends Vue {
dynamic = false
get isDynamic () {
if (this.dynamic) {
return TestDynamicChildView
}
}
}
</script>
<style scoped>
/* dynamic */
.dynamic-enter-active, .dynamic-leave-active {
transition: all .3s ease;
}
.dynamic-enter, .dynamic-leave-to {
transform: translateX(50px);
}
</style>
반응형
'Frontend > Vue' 카테고리의 다른 글
[Vue + typescript] 숫자 tween (0) | 2022.05.11 |
---|---|
[Vue + typescript] transition (0) | 2022.05.04 |
[VUE + TYPESCRIPT] font-awesome 설치 (0) | 2022.04.28 |
[VUE + TYPESCRIPT] vue splitpanes (0) | 2022.04.20 |
[VUE + TYPESCRIPT] 메세지 추가 애니메이션 (0) | 2022.03.25 |
Comments