<!DOCTYPE html>
<html> <head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script>
<style>
* {
margin: 0;
padding: 0;
} li {
list-style: none
} body {
height: 2000px;
overflow: hidden;
} .header {
width: 100%;
height: 40px;
background: #e1e1e1;
text-align: center;
line-height: 40px;
position: fixed;
} .header button {
padding: 0rem 0.2rem;
height: 40px;
top: 0;
} .header button:nth-of-type(1) {
position: fixed;
left: 0;
} .header button:nth-of-type(2) {
position: fixed;
right: 0;
}
</style>
</head> <body>
<div id="app">
<custom-header :title="title">
<button slot="left">返回</button>
</custom-header>
</div> <template id="header">
<div class="header">
<slot name="left"></slot>
<span>{{title}}</span>
<slot name="right"></slot>
</div>
</template> <script>
Vue.component("custom-header", {
template: '#header',
props: ["title"]
});
//多插槽的使用,则使用name属性来指定要插入的位置
var vm = new Vue({
el: '#app',
data: {
title: "通讯录"
},
components: { }
});
</script> </body> </html>

Vue创建头部组件示例的更多相关文章

  1. Vue创建局部组件

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. Vue创建全局组件

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. Vue.js使用-组件示例(实现数据的CRUD)

    1.业务场景 用户(姓名,年龄,性别)的增删改查 2.数据格式 定义字段,name:字段名称,iskey:是否主键(添加,修改数据标志),dataSource:可选列表(下拉框选项) columns: ...

  4. vue 访问子组件示例 或者子元素

    1.子组件 <base-input ref="usernameInput"></base-input> this.$refs.usernameInput 2 ...

  5. Vue列表组件与弹窗组件示例

    列表组件 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <me ...

  6. vue通过extend动态创建全局组件(插件)学习小记

    测试环境:nodejs+webpack,例子是看文章的,注释为自己的理解 创建一个toast.vue文件: <template> <div class="wrap" ...

  7. Vue 创建组件的方式

    Vue 创建组件的方式 2018年08月07日 11:10:56 虔诚带着决然 阅读数:1015   版权声明:本文为博主原创文章,未经博主允许不得用做其他商业活动. https://blog.csd ...

  8. vue 创建单文件组件 注册组件 以及组件的使用

    <template> <div id="app"> <v-home></v-home> <hr > <br> ...

  9. vue创建组件

    vue创建组件是很容易的: js: Vue.component("component-item",{   //component-item就是我们在HTML页面上引用的组件,它会在 ...

随机推荐

  1. RN中API之NetInfo--浅谈

    我们在做移动端项目和手机APP应用时,避免不了要获取用户手机的网络状况.在使用RN技术开发APP时,其内置的NetInfo API就是为了解决这一问题的.下面简单的讲下NetInfo如何使用. 最新的 ...

  2. apache kafka技术分享系列(目录索引)

    https://blog.csdn.net/lizhitao/article/details/39499283 https://blog.csdn.net/lizhitao

  3. .NET Core 管道过滤器扩展

    if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseEx ...

  4. async await与promise

    1.async 的返回值一定是一个promise.,即使你的函数里没有return. // 测试async的返回值 async function testAsync() { } let result ...

  5. SDWebImage 的简单使用方法

    第一步,下载SDWebImage,导入工程 第二步,在需要的地方导入头文件:#import   "UIImageView+WebCache.h" 第三步,调用sd_setImage ...

  6. 一个完整的成年果蝇大脑的电子显微镜图谱 | A Complete Electron Microscopy Volume of the Brain of Adult Drosophila melanogaster

    paper:A Complete Electron Microscopy Volume of the Brain of Adult Drosophila melanogaster 果蝇是一个非常完美的 ...

  7. SparkSql处理嵌套json数据

    一.数据准备: { "dc_id": "dc-101", "source": { "sensor-igauge": { ...

  8. SOAP和REST

    SOAP: Simple Object Access Protocol REST: Representation State Transfer SOAP的简单介绍 SOAP可使用多种协议进行传输,用于 ...

  9. SWUST OJ(963)

    小偷的背包 #include<stdio.h> #include<stdlib.h> int s, flag, n, *a; //主函数之外定义的变量为全局变量 void df ...

  10. (译)xDS REST and gRPC protocol

    xDS REST and gRPC protocol 原文地址:xDS REST and gRPC protocol. envoy可通过文件系统.一个或多个管理服务器来发现各种动态资源.这些服务发现和 ...