我正在将Nuxt与Typescript一起使用。我创建以下组件:
<template>
<div class="field">
<label class="label" v-if="typeof label !== 'undefined'">{{ label }}</label>
<div class="control">
<textarea
v-if="inputType === 'textarea'"
class="textarea"
@input="$emit('input', $event.target.value)"
></textarea>
<input
v-if="inputType === 'input'"
:type="type"
class="input"
@input="$emit('input', $event.target.value)"
>
</div>
</div>
</template>
<script lang="ts">
import { Vue, Component, Prop } from "vue-property-decorator"
@Component({})
export default class AppInput extends Vue {
@Prop({ type: String, required: false, default: "input" })
inputType!: string
@Prop({ type: String, required: false })
label!: string
@Prop({ type: String, required: false, default: "text" })
type!: string
}
</script>
<style>
</style>
然后在中@/plugins/components.ts
,我按如下所示导入组件:
import Vue from "vue"
import AppInput from "@/components/Forms/AppInput.vue"
Vue.component("AppInput", AppInput)
当我用Nuxt编译项目时,会抛出export 'default' (imported as 'mod') was not found
错误。请帮忙!
我使用以下tsconfig解决了: