是否可以在外部文件(.html)中找到模板的Vue组件?我们可以对样式(.scss)执行同样的操作吗?
这将有助于我们的开发,让前端HTML开发人员处理HTML和样式,javascript开发人员处理组件逻辑和行为。
是否可以在vue组件中引用/导入模板和样式?
答案是肯定的,但组件的条目将包含模板,而不是脚本。从…起 Single File Components section Vue的。js文档:
即使您不喜欢单文件组件的想法,也可以通过将JavaScript和CSS分离为单独的文件来利用其热重新加载和预编译功能: <!-- my-component.vue --> <template> <div>This will be pre-compiled</div> </template> <script src="./my-component.js"></script> <style src="./my-component.css"></style>
即使您不喜欢单文件组件的想法,也可以通过将JavaScript和CSS分离为单独的文件来利用其热重新加载和预编译功能:
<!-- my-component.vue --> <template> <div>This will be pre-compiled</div> </template> <script src="./my-component.js"></script> <style src="./my-component.css"></style>