Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vue component cannot be loaded correctly when data have some specific names #91

Open
7 tasks done
supergem3000 opened this issue Aug 28, 2023 · 1 comment
Open
7 tasks done

Comments

@supergem3000
Copy link

Describe the bug

when i migrate my project from vue-cli to vite, i meet an unexpected problem!
vue component cannot be loaded correctly when data have some specific name
code is below:

<template>
  <div>
    <div>EXPORT ISSUES</div>
    <div>{{ showData }}</div>
  </div>
</template>

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

@Component({
  name: 'ExportIssues',
})
export default class ExportIssues extends Vue {
  fieldInfo = { default: [] };

  showData = '';
  exportType = 'xlsx';

  get getter() {
    return this.fieldInfo.default;
  }

  created() {
    this.showData = 'loaded correctly';
  }
}
</script>

created method will not run.
if delete the line exportType = 'xlsx'; or the getter method, this component will run correctly

I guess its a bug of the compiler. It reads the 'export', 'default' word and do something wrong.

Need your help!


将项目从VueCLI迁移到Vite时遇到了问题。代码如上文。当Vue组件有一个数据叫exportType,一个getter中包含叫default的取值时,这个组件无法正常运行,created方法不执行。把exportType = 'xlsx';那行或者getter删掉就正常了。
猜测是编译器把exportdefault读到了一起,然后编译错了东西?
需要你的帮助!

Reproduction

https://stackblitz.com/edit/vitejs-vite-s1r7wy?file=src%2Fcomponents%2FExportIssues.vue

Steps to reproduce

No response

System Info

System:
    OS: macOS 13.4.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 166.40 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.16.0/bin/yarn
    npm: 7.10.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
  Browsers:
    Chrome: 116.0.5845.110
    Safari: 16.5.2
  npmPackages:
    @vitejs/plugin-vue2: ^2.2.0 => 2.2.0 
    vite: 4.4.9 => 4.4.9

Used Package Manager

yarn

Logs

No response

Validations

@stackblitz
Copy link

stackblitz bot commented Aug 28, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@sapphi-red sapphi-red transferred this issue from vitejs/vite Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant