【发布时间】:2020-07-08 12:22:34
【问题描述】:
我有一个简单的带有递归的打字稿组件:
<template>
<div :style="{ paddingLeft: depth * 20 + 'px' }">
<h1>Level {{ depth }}</h1>
<div v-if="depth < 2">
<Recursive v-for="i in 3" :key="i" :depth="depth + 1"/>
</div>
</div>
</template>
<script lang="ts">
import * as Vue from "vue";
import { Component, Prop } from "vue-property-decorator";
@Component({
components: { Recursive }
})
class Recursive extends Vue {
@Prop({ required: true })
depth!: number;
}
export default Recursive;
</script>
演示: https://codesandbox.io/s/vue-typescript-recursive-12u3q?file=/src/components/Recursive.vue
在开发模式下运行良好。
但是一旦我进行构建 - 递归导入将被编译成这些类型的字符串:
<!--function(e,n,r,o){return ln(t,e,n,r,o,!0)}--> 而不是 html。
我应该怎么做才能使递归正常工作?
【问题讨论】:
标签: typescript vue.js recursion