首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >获得无原因的解析错误类型记录,Vue,vue-property-decorator,VSCode

获得无原因的解析错误类型记录,Vue,vue-property-decorator,VSCode
EN

Stack Overflow用户
提问于 2020-05-28 07:36:11
回答 1查看 526关注 0票数 0

我对打字稿和Vue.js完全陌生,我在这里找不到任何解决办法。

下面的代码给出了解析错误:“}”预期

我检查了所有的托槽对,在我看来没有什么不对的。

基本代码在这里。我从完全工作的基本例子中分叉出来的。https://github.com/hanachan1026/vue-firebase-startup-kit

代码语言:javascript
复制
// Hello.vue
<template>
  <section class="section">
    <div class="container">
      <h1 class="title">
        Hello
        {{userName}}
      </h1>
      <p>Firebase rocks!</p>
      <img id="img1" src="" alt="img1" />
    </div>
  </section>
</template>

<script lang="ts">
import { storage } from "../scripts/firebase";
import Vue from "vue";
import { Component } from "vue-property-decorator";

@Component
export default class Home extends Vue {
  created() { 
    const storageRef = storage.ref();

    const imagesRef = storageRef.child('images');

    const fileName = 'IMG_1009.JPG';

    const imgRef = imagesRef.child(fileName);

    imgRef.getDownloadURL().then(function (url) {
      const img: HTMLImageElement = <HTMLImageElement>document.getElementById('img1');

      img.src = url;
    }).catch(function(error) {
      console.log(error); // <= parse error here. why?
    });
  }

  get userName(): string {
    if (this.$store.state.user) {
      return this.$store.state.user.displayName;
    }
    return "";
  }
}
</script>

我知道这不容易回答,因为会有很多原因。如果你有任何类似的经验,我希望任何意见。谢谢。

*加入

代码语言:javascript
复制
➤ npm run serve

> vue_kit@0.1.0 serve /Users/me/show-cam-img-demo
> vue-cli-service serve

 INFO  Starting development server...
Starting type checking service...
Using 1 worker with 2048MB memory limit
98% after emitting CopyPlugin

 ERROR  Failed to compile with 1 errors                                                                                                                                                                                                                           3:34:02 PM

 error  in ./src/views/Hello.vue

Module Error (from ./node_modules/eslint-loader/index.js):

/Users/me/show-cam-img-demo/src/views/Hello.vue
  35:24  error  Parsing error: '}' expected

✖ 1 problem (1 error, 0 warnings)


 @ ./src/router/index.ts 4:0-37 9:13-17
 @ ./src/main.ts
 @ multi (webpack)-dev-server/client?http://192.168.1.37:8080/sockjs-node (webpack)/hot/dev-server.js ./src/main.ts

No type errors found
Version: typescript 3.8.3
Time: 20252ms
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-05-28 16:12:20

错误发生在eslint中。你必须要用于类型记录和vue的配置eslint

直到2019年,tslint和vue-tslint装载机都是解决方案。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62059338

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档