'Uncaught TypeError: Class extends value undefined is not a constructor or null' when trying to load external TypeScript component
'Uncaught TypeError: Class extends value undefined is not a constructor or null' when trying to load external TypeScript component
我已经准备好可以使用此 npx 命令(运行 在 PowerShell 中)构建我的组件的地方:
&npx vue-cli-service build `
--target lib `
--formats umd-min `
--no-clean `
--dest $destinationFolder `
--name $component.Name $component.FullName
然后我按照 this article
将它们导入我的 vue 应用程序
用JS编写组件时工作正常,但是当我尝试在TS中制作一个时,我得到了这个错误:
file:7 Uncaught TypeError: Class extends value undefined is not a constructor or null
at Module.fb15 (file:7)
at r (file:1)
at 8875 (file:1)
at file:1
at file:1
at file:1
我的 TypeScript vue 组件真的很简单:
<template>
<h1>A lovely typescript component</h1>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
@Component({
name: 'TypeScriptTest'
})
export default class TypeScriptTest extends Vue { }
</script>
我确实尝试过像这样导入 vue:
import Vue from 'vue'
但是没有效果
有谁知道我该如何解决这个问题?
我将此行添加到我的 html 文件的顶部:
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
错误消失了,我的 TypeScript 组件导入成功
这似乎不是一个理想的解决方案,但确实有效
我已经准备好可以使用此 npx 命令(运行 在 PowerShell 中)构建我的组件的地方:
&npx vue-cli-service build `
--target lib `
--formats umd-min `
--no-clean `
--dest $destinationFolder `
--name $component.Name $component.FullName
然后我按照 this article
将它们导入我的 vue 应用程序用JS编写组件时工作正常,但是当我尝试在TS中制作一个时,我得到了这个错误:
file:7 Uncaught TypeError: Class extends value undefined is not a constructor or null
at Module.fb15 (file:7)
at r (file:1)
at 8875 (file:1)
at file:1
at file:1
at file:1
我的 TypeScript vue 组件真的很简单:
<template>
<h1>A lovely typescript component</h1>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
@Component({
name: 'TypeScriptTest'
})
export default class TypeScriptTest extends Vue { }
</script>
我确实尝试过像这样导入 vue:
import Vue from 'vue'
但是没有效果
有谁知道我该如何解决这个问题?
我将此行添加到我的 html 文件的顶部:
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
错误消失了,我的 TypeScript 组件导入成功
这似乎不是一个理想的解决方案,但确实有效