admin管理员组文章数量:1314832
I want to separate the vue.js template into a .vue file while leaving code in a .js file.
This is a vue "single file ponent":
<template>
..
</template>
<script>
..
</script>
What works:
Make the .vue file the real ponent, and define a MIXIN that points to the .js file. Seems very hacky!
What I would like:
A single webpack import to the .js file:
...
</template>
import ViewModel from 'vm.js'
Is this possible? Or a tag in the .vue file that vue-loader understands?
<template>
..
<script src='vm.js'/>
</template>
Thanks a ton! The goal is to set breakpoints in visual studio code + separation of concerns + readability. :)
Oh, and this needs to work with typescript!
I want to separate the vue.js template into a .vue file while leaving code in a .js file.
This is a vue "single file ponent":
<template>
..
</template>
<script>
..
</script>
What works:
Make the .vue file the real ponent, and define a MIXIN that points to the .js file. Seems very hacky!
What I would like:
A single webpack import to the .js file:
...
</template>
import ViewModel from 'vm.js'
Is this possible? Or a tag in the .vue file that vue-loader understands?
<template>
..
<script src='vm.js'/>
</template>
Thanks a ton! The goal is to set breakpoints in visual studio code + separation of concerns + readability. :)
Oh, and this needs to work with typescript!
Share Improve this question asked Apr 29, 2018 at 15:32 EdzaEdza 1,4443 gold badges15 silver badges24 bronze badges 2- 1 As someone who is still learning vue, from what I understand is that vue needs the template/js in one file in order for it to be piled into a ponent for web usage. However, if this is in fact possible I would like to know as well... – Get Off My Lawn Commented Apr 29, 2018 at 15:36
- Can't you just wrap the import in script tags? – pishpish Commented Apr 29, 2018 at 15:58
1 Answer
Reset to default 7...
</template>
import ViewModel from 'vm.js'
The second option is possible with a small tweak made in it
<template>
...
</template>
<script src="vm.js"></script>
本文标签: javascriptHow to separate vuejs template into a vue file while leaving code in jsStack Overflow
版权声明:本文标题:javascript - How to separate vue.js template into a .vue file while leaving code in .js? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741972303a2407913.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论