Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在带有Typescript的视图中使用Vue单文件组件?_Typescript_Vue.js_Yarnpkg - Fatal编程技术网

如何在带有Typescript的视图中使用Vue单文件组件?

如何在带有Typescript的视图中使用Vue单文件组件?,typescript,vue.js,yarnpkg,Typescript,Vue.js,Yarnpkg,我尝试过很多方法,但总是会遇到一些构建或运行时错误。我有点惊讶,我没有能够找到一个工作的例子或职位后,经过大量的搜索。我使用Vue UI使用Typescript创建了一个新项目,然后创建了以下组件: <template> <div class="navigation"> BACK | NEXT buttons go here </div> </template> <script lang="ts

我尝试过很多方法,但总是会遇到一些构建或运行时错误。我有点惊讶,我没有能够找到一个工作的例子或职位后,经过大量的搜索。我使用Vue UI使用Typescript创建了一个新项目,然后创建了以下组件:

<template>
  <div class="navigation">
    BACK | NEXT buttons go here
  </div>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";

@Component
export default class BackNext extends Vue {
}
</script>
现在还不清楚一个启用了Typescript支持的标准新项目是否需要安装一系列依赖项才能使用一些非常标准的功能,我不想通过安装一系列可能需要或不需要的东西来进一步打乱我的项目

npm版本6.13.4

节点版本12.16.1

纱线版本1.22.4


vue version@vue/clu 4.5.3

您需要在decorator中注册它

从“../../components/BackNext.vue”导入BackNext;
@组成部分({
组成部分:{
下一步,
},
})
导出默认类个人扩展Vue{
私有数据项=[];
...

“一个.view文件”在他们当前的问题列表中看不到类似的内容。您是否尝试过可靠的旧
rm-r node_modules package-lock.json&&npm安装
?我指的是.vue视图文件。该项目是一个SPA,其中包含视图子目录中的页面。在运行
之前,您是否删除了
package lock.json
以及
node_modules
失速
?这是Thread.lock文件,在删除并运行Thread之后安装npm run serve works。谢谢!
<template>
  <div class="question">
    <h1>Personal</h1>
    <back-next />
  </div>
</template>
<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import BackNext from "../../components/BackNext.vue";
@Component
export default class Personal extends Vue {
  components = {
    'back-next': BackNext
  }
}
</script>
 ERROR  Failed to compile with 11 errors4:22:27 PM

These dependencies were not found:

* core-js/modules/es.object.get-prototype-of in ./node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js
* core-js/modules/es.object.to-string in ./node_modules/@babel/runtime/helpers/esm/isNativeReflectConstruct.js, ./node_modules/@babel/runtime/helpers/esm/typeof.js
* core-js/modules/es.reflect.construct in ./node_modules/@babel/runtime/helpers/esm/createSuper.js, ./node_modules/@babel/runtime/helpers/esm/isNativeReflectConstruct.js
* core-js/modules/es.regexp.to-string in ./node_modules/@babel/runtime/helpers/esm/isNativeReflectConstruct.js
* core-js/modules/es.string.iterator in ./node_modules/@babel/runtime/helpers/esm/typeof.js
* core-js/modules/es.symbol in ./node_modules/@babel/runtime/helpers/esm/typeof.js
* core-js/modules/es.symbol.description in ./node_modules/@babel/runtime/helpers/esm/typeof.js
* core-js/modules/es.symbol.iterator in ./node_modules/@babel/runtime/helpers/esm/typeof.js
* core-js/modules/web.dom-collections.iterator in ./node_modules/@babel/runtime/helpers/esm/typeof.js

To install them, you can run: npm install --save core-js/modules/es.object.get-prototype-of core-js/modules/es.object.to-string core-js/modules/es.reflect.construct core-js/modules/es.regexp.to-string core-js/modules/es.string.iterator core-js/modules/es.symbol core-js/modules/es.symbol.description core-js/modules/es.symbol.iterator core-js/modules/web.dom-collections.iterator