Skip to content

<script lang="tsx"> Compilation error #1399

Closed
@ccqiuqiu

Description

@ccqiuqiu

Version

3.0.0-beta.14

Reproduction link

https://github.com/ccqiuqiu/vue-cli3-test

Steps to reproduce

1.使用vue-cli创建一个项目,选择babel、ts
2.修改home.vue,增加一个component组件,如下:

<template>
  <div class="home">
    <img src="../assets/logo.png">
    <HelloWorld msg="Welcome to Your Vue.js   TypeScript App"/>
    <component :is="component"></component>
  </div>
</template>

<script lang="tsx">
import { Component, Vue } from 'vue-property-decorator';
import HelloWorld from '@/components/HelloWorld.vue'; // @ is an alias to /src

@Component({
  components: {
    HelloWorld,
  },
})
export default class Home extends Vue {
  private component: any = {
    render: (h: any) => <div>dddd</div>
  }
}
</script>
  1. 修改tsconfig.json中的target为es5
    4.运行 npm run serve

What is expected?

希望能正常渲染jsx

What is actually happening?

异常信息

> vue-cli3@0.1.0 serve /Users/cc/Desktop/node/vue-cli3
> vue-cli-service serve

 INFO  Starting development server...
Starting type checking service...
Using 1 worker with 2048MB memory limit
 94% after seal

 ERROR  Failed to compile with 1 errors                                                                                                                                         09:51:42

 error  in ./src/views/Home.vue?vue&type=script&lang=tsx

Syntax Error: Unterminated regular expression (13:35)

  11 |         super(...arguments);
  12 |         this.component = {
> 13 |             render: (h) => dddd < /div>
     |                                    ^
  14 |         };
  15 |     }
  16 | };


 @ ./src/views/Home.vue?vue&type=script&lang=tsx 1:0-268 1:284-287 1:289-554 1:289-554
 @ ./src/views/Home.vue
 @ ./src/router.ts
 @ ./src/main.ts
 @ multi (webpack)-dev-server/client/index.js (webpack)/hot/dev-server.js ./src/main.ts

No type errors found
Version: typescript 2.8.3
Time: 3320ms


此异常通常在第一次启动的时候出现,重启有时候会正常,但是修改代码后,再重启又可能出现异常。

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions