标题栏控件

这一节来实现一个简单的vue组件,自定义标题名组件,可以用作于构件自定义系统名称,下面来看代码。

<template>
    <div>
        <div class="header">
            <p class="customtitle">{{this.$props.title}}</p>
        </div>
    </div>
    
</template>
<script>
export default {
    name:"customheader",
    props:{
        title:{
            type:String,
            default:"XXXXXX"
        }
    }
}
</script>
<style>
    .header{
        position: absolute;
        top: 0;
        height: 70px;
        left: 0;
        width: 100%;
        background: url('../../assets/header.png') no-repeat;
        background-size: 100% 100%;
        background-color: rgba(0, 0, 0, 0);
        text-align: center;
        color: whitesmoke;
        font-size: 18px;
        vertical-align: middle;
        z-index: 99999;
        
    }
    .customtitle{
        width: 100%;
        height: 100%;
        text-align: center;
        vertical-align: middle;
        font-size: 32px;
        color: whitesmoke;
        margin-top: 15px;
    }
</style>

这里核心是利用vue的props属性,接收来自于父组件的传递的参数,实现自定义的标题名。

<customheader title="CustomDemo"></customheader>
自定义标题名
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。