<template> <div> <myComponent></myComponent> </div> </template> <script> //使用import导入自定义的组件,es6的引入机制,推荐使用 import myComponent from './myComponent.vue' export default { //在components中写入子组件 components: {myComponent}, } </script> <style></style>
<template> <div> <myComponent></myComponent> </div> </template> <script> export default { //1.直接在components中写入子组件时给出引入路径,es5写法 components: { myComponent:require('./myComponent.vue').default }, } </script>
https://blog.csdn.net/lzzattack03x/article/details/79244687