1.main.js

import Vue from 'vue'
import FastClick from 'fastclick'
import VueRouter from 'vue-router'
import App from './App' // 自定义的路由文件
import router from './router' // 解决300ms延迟问题
FastClick.attach(document.body) Vue.config.productionTip = false /* eslint-disable no-new */
new Vue({
el: '#app-box',
router,
template: '<App/>',
components: { App }
})

2.路由 router/index.js

import Vue from 'vue'
import Router from 'vue-router'
// 首页
import Home from '@/pages/Home/Home'
// 我的设置
import MySettings from '@/pages/MySettings/MySettings' Vue.use(Router) // 路由配置
export default new Router({
routes: [
// 首页
{
path: '/',
name: 'Home',
component: Home
},
// 我的设置
{
path: '/mySettings',
name: 'MySettings',
component: MySettings
},
{
path: '/home',
redirect: '/'
},
{
path: '*',
redirect: '/'
},
]
})

3.主页面 App.vue

<template>
<div id="app">
<!-- 视图层 -->
<router-view></router-view>
</div>
</template> <script>
export default {
//
}
</script> <style lang="less">
@import '~vux/src/styles/reset.less'; body {
background-color: #fbf9fe;
line-height: 1.2;
}
</style>

4.Header 组件

Header.vue

<!-- 顶部 标题栏 -->
<template>
<div>
<!-- 标题栏 -->
<x-header :left-options="{showBack: false}" style="background-color:#00CC66;">{{tag}}</x-header>
</div>
</template> <script>
// 引入组件
import { XHeader, Tabbar, TabbarItem } from 'vux' export default {
name: 'AppHeader',
data(){
return {
tag: '首页',
showMenus: false
}
},
components: {
XHeader,
Tabbar,
TabbarItem
}
}
</script> <style lang="less" scoped>
.tabbar{
background-color: #00CC66;
height: 50px;
position: relative;
}
</style>

5.页面调用 Home.vue

<!-- 首页 -->
<template>
<div>
<!-- 顶部 标题栏 -->
<app-header></app-header>
</div>
</template> <script>
import AppHeader from '../../components/Header' export default {
name: 'Home',
components: {
AppHeader
},
data(){
return {
//
}
}
}
</script> <style lang="less" scoped></style>

6.效果图

vue2.0 + vux (一)Header 组件的更多相关文章

  1. Vue2.0表单校验组件vee-validate的使用

    vee-validate使用教程 *本文适合有一定Vue2.0基础的同学参考,根据项目的实际情况来使用,关于Vue的使用不做多余解释.本人也是一边学习一边使用,如果错误之处敬请批评指出* 一.安装 n ...

  2. Vue2.0的变化 ,组件模板,生命周期,循环,自定义键盘指令,过滤器

    组件模板: 之前: <template> <h3>我是组件</h3><strong>我是加粗标签</strong> </templat ...

  3. Webpack+vue2.0如何注册全局组件 (01)

    Part 1, 问题: webpack + vue2.0框架中,如何在入口js中注册组件? 就是在一个月以前,匆匆闯入vuejs这个社群,基本了解了vuejs的一些基础特性和语法.笔者兴致勃勃地开始想 ...

  4. vue2.0开发时导入组件时出错

    导入自定义组件时出现了如下错误 ERROR Failed to compile with 1 errors 12:35:41 This dependency was not found: * comp ...

  5. Vue2.0中的transition组件

    组件的过度 Vue1.0中transition做为标签的行内属性被vue支持.但在Vue2.0中.Vue放弃了旧属性的支持并提供了transition组件,transition做为标签被使用. 使用t ...

  6. Vue2.0如何实现父组件与子组件之间的事件发射与接收

    关于vue2.0的事件发射和接收,大家都知道$dispatch和$broadcast在vue2.0已经被弃用了,取而代之的是更加方便快捷的方式,使用事件中心,组件通过它来互相通信,不管组件在哪一个层都 ...

  7. 在vue2.0中引用element-ui组件库

    element-ui是由饿了么团队开发的一套基于 Vue 2.0 的桌面端组件库. 官网:http://element.eleme.io/ 安装 npm i element-ui -S 引用完整的el ...

  8. vue2.0 + vux (二)Footer组件

    1.Footer组件 Footer.vue <!-- 底部 footer --> <template> <div> <tabbar> <!-- 综 ...

  9. vue2.0 + vux (四)Home页

    1.综合页(首页) Home.vue <!-- 首页 --> <template> <div> <!-- 顶部 标题栏 --> <app-head ...

随机推荐

  1. Deep Android Malware Detection小结

    题目:Deep Android Malware Detection 作者:Niall McLaughlin, Jesus Martinez del Rincon, BooJoong Kang 年份:2 ...

  2. [python篇] [伯乐在线][1]永远别写for循环

    首先,让我们退一步看看在写一个for循环背后的直觉是什么: 1.遍历一个序列提取出一些信息 2.从当前的序列中生成另外的序列 3.写for循环已经是我的第二天性了,因为我是一个程序员 幸运的是,Pyt ...

  3. API生命周期

    这一系列的文章,主要是结合了参加Oracle code之后对于API治理的记录收获,以及回到公司后,根据公司目前的一些现状,对此加以实践的过程总结 API生命周期通常包括八个内容,而安全策略贯穿始终. ...

  4. Event based Collections

    https://sourceforge.net/p/happy-guys/wiki/Event%20based%20Collections/

  5. 【bzoj2563】阿狸和桃子的游戏 贪心

    题目描述 阿狸和桃子正在玩一个游戏,游戏是在一个带权图G=(V, E)上进行的,设节点权值为w(v),边权为c(e).游戏规则是这样的:1. 阿狸和桃子轮流将图中的顶点染色,阿狸会将顶点染成红色,桃子 ...

  6. 学习 WebService 第五步:在Local创建测试用WebService(WSDL)

    [准备] Eclipse+Tomcat7(Tomcat端口修改为不冲突的值) axis2 1.7.7 jar包(没有来这里下载:http://www.apache.org/dyn/closer.lua ...

  7. 用户认证系统 django.contrib.auth模块

    一 导入auth模块 from django.contrib.auth.models import User from django.contrib import auth auth模块的操作针对的就 ...

  8. Discrete Logging(poj 2417)

    高次同余方程.   BL == N (mod P)求解最小的L. /* A^x=B(mod C) 设x=i*m-j(其中m=ceil(sqrt C)) 并且i∈[1,m],j∈[0,m],以保证x能取 ...

  9. 洛谷 [P3455] ZAP

    莫比乌斯函数 #include <iostream> #include <cstdio> #include <cmath> #include <cstring ...

  10. transform与position:fixed的那些恩怨--摘抄

    1. 前言 在写这篇文章之前,我理解的fixed元素是这样的:(摘自CSS布局基础) 固定定位与absolute定位类型类似,但它的相对移动的坐标是视图(屏幕内的网页窗口)本身.由于视图本身是固定的, ...