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

Auto-import component in <script> when using component in template/javascript #684

Closed
octref opened this issue Feb 7, 2018 · 17 comments · Fixed by #2445
Closed

Auto-import component in <script> when using component in template/javascript #684

octref opened this issue Feb 7, 2018 · 17 comments · Fixed by #2445

Comments

@octref
Copy link
Member

octref commented Feb 7, 2018

Similar to JS/TS's auto import in VS Code: https://code.visualstudio.com/updates/v1_18#_auto-import-for-javascript-and-typescript

@octref
Copy link
Member Author

octref commented Feb 7, 2018

As a note, need to look into how to resolve path aliases...

@alexbudure
Copy link

+1

@sanwv
Copy link

sanwv commented May 29, 2018

+1

hope import absolute path like @/compoents/CommonComp.vue. path alias @ defined in jsconfig.json

@adams549659584
Copy link

+1

3 similar comments
@Terry-Su
Copy link

Terry-Su commented Jul 6, 2018

+1

@dotgreg
Copy link

dotgreg commented Jul 30, 2018

+1

@rothsandro
Copy link

+1

@octref octref mentioned this issue Aug 13, 2018
17 tasks
@octref octref changed the title Auto-import component in <script> when typing corresponding components in <template>, Auto-import component in <script> when using component in template/javascript Dec 16, 2018
@zamboney
Copy link

zamboney commented Feb 4, 2019

+1

1 similar comment
@slanden
Copy link

slanden commented Feb 24, 2019

+1

@Terry-Su
Copy link

after a long while I reviewed the progress today, and still found auto import via alias not working. However, found a very useful tool, not perfect but enough for auto importing vue components and js variables using alias(remember to use shortcut to import vue components):
vue-helper

@jd-solanki
Copy link

+1

@RobertLemmens
Copy link

+1, moving from webstorm to vscode + vetur, i find this one of the biggest features im missing.

@wanxe
Copy link

wanxe commented Jul 23, 2020

This is failing again after the last release. Works again by reverting the version to the previous one.

@mrguamos
Copy link

any update on this?

yoyo930021 added a commit to yoyo930021/vuter that referenced this issue Nov 8, 2020
yoyo930021 added a commit to yoyo930021/vuter that referenced this issue Nov 8, 2020
yoyo930021 added a commit to yoyo930021/vuter that referenced this issue Nov 9, 2020
yoyo930021 added a commit to yoyo930021/vuter that referenced this issue Nov 9, 2020
yoyo930021 added a commit to yoyo930021/vuter that referenced this issue Nov 9, 2020
@danranVm
Copy link

vetur

@yoyo930021 hi, it doesn’t work, when I don’t use export default, but name the component.

@pikax
Copy link
Member

pikax commented Nov 12, 2020

@danranVm that's not a valid SFC component SFC spec please use export default if you are exporting a vue component

Your HelloWorld.vue component won't work, you can test by:

<template>a = {{ a }}</template>
<script lang="ts">
import {defineComponent} from 'vue'
export const HelloWorld = defineComponent({
  setup() {
    return {
      a: 1,
    };
  },
});
</script>

EDIT:

Which will only render a = instead of a = 1

Also the compiled component will be:

import {defineComponent} from "/@modules/vue.js";
export const HelloWorld = defineComponent({
  setup() {
    return {
      a: 1
    };
  }
});

const __script = {}
import { render as __render } from "path/HelloWorld.vue?type=template"
__script.render = __render
__script.__hmrId = "path/HelloWorld.vue"
__script.__file = "path\\HelloWorld.vue"
export default __script

@danranVm
Copy link

@pikax I see. thank you for your answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.