Vue组件

var com1 = Vue.extend({template:'<h3>使用Vue.extend创建组件</h3>'})
Vue.component('myCom1',com1)
Vue.component('mycom1',{
    template:'<h3>这是用Vue-template创建的元素</h3>'
})
<login v-if="flag"></login>
<register v-else="flag"></register>
<component :is="'comname'"></component>
在组件内部显式定义props:[]用来得到父组件传过来的值
<template>
<div>
    <comson :fatherinfo="'hhh'" @fuck="fuck"></comson>
</div>
</template>

<script>

var comson = {
    data(){
        return {
            msg:666
        }
    },
    methods:{
        myfuck(){
            this.$emit('fuck')
        }
    },
    props:['fatherinfo'],

    template:`<div>
        <h3>{{msg}}{{fatherinfo}}</h3>
        <input type="button" value="点我啊" @click="myfuck"></input>
    </div>`
}

export default {
    methods:{
        fuck(){
            alert('fuck you')
        }
    },
    components:{
        comson
    }
}

</script>

<style lang='less' scoped>

</style>