vue引用组件的两个方法

<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

posted @ 2019-01-26 16:31  WayneLiu123  阅读(7370)  评论(0编辑  收藏  举报