vue + vue-router+vuex+elementUI开发环境搭建
先在npm中安装vue脚手架,
//先安装国内镜像源
npm install -g cnpm --registry=https://registry.npm.taobao.org //安装vue
cnpm install --global vue-cli //创建一个项目
vue init webpack my-project //安装依赖
cd my-project
cnpm install //加入vue-router
cnpm install vue-router --save //加入vuex
cnpm install vuex --save //加入elementUI
cnpm i element-ui -S
页面布局
先App.vue
<template>
<div id="app">
<router-view/>
</div>
</template> <script> export default {
name: 'app',
}
</script> <style>
body {
margin: 0;
padding: 0;
font-size: 12px;
}
</style>
再Home.vue
<template>
<el-container class="is-vertical">
<my-header></my-header>
<el-container>
<el-aside width="230px">
<el-menu class="el-menu-vertical-demo" @open="handleopen" @close="handleclose" @select="handleselect"
unique-opened router background-color="#333d52"
text-color="#fff">
<template v-for="(item,index) in $router.options.routes" v-if="!item.hidden">
<el-submenu :index="index+''" v-if="!item.leaf">
<template slot="title"><i :class="item.iconCls"></i>{{item.name}}</template>
<el-menu-item v-for="child in item.children" :index="child.path" :key="child.path" v-if="!child.hidden">
{{child.name}} </el-menu-item>
</el-submenu>
<el-menu-item v-if="item.leaf&&item.children.length>0" :index="item.children[0].path"><i :class="item.iconCls"></i>{{item.children[0].name}}</el-menu-item>
</template>
</el-menu>
</el-aside>
<el-main>
<router-view></router-view>
</el-main>
</el-container>
</el-container>
</template> <script>
import header from './header'
export default {
methods: {
handleopen() {
//console.log('handleopen');
},
handleclose() {
//console.log('handleclose');
},
handleselect: function (a, b) {
},
},
components: {
'my-header': header,
}
}
</script>
因header重新注册了一个新的组件
<template>
<el-header>
<el-row :gutter="12">
<el-col :span="3" class="logo-width"><img src="../img/top_icon.png" alt=""></el-col>
<el-col :span="6">
<el-dropdown>
<span class="el-dropdown-link">
<i class="el-icon-setting" style="margin-right: 10px"></i><span>admin</span>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item>设置</el-dropdown-item>
<el-dropdown-item>修改密码</el-dropdown-item>
<el-dropdown-item>退出</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</el-col>
<el-col :span="6" class="userinfo">
<el-dropdown>
<span type="primary">admin</span>
<!--<i class="el-icon-setting" style="margin-right: 15px"></i>-->
<el-dropdown-menu slot="dropdown">
<el-dropdown-item>设置</el-dropdown-item>
<el-dropdown-item>修改密码</el-dropdown-item>
<el-dropdown-item>退出</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<span>|</span>
<el-button type="text">退出</el-button>
</el-col>
</el-row>
</el-header>
</template> <script> </script> <style scoped>
.el-header {
background: #373d41;
color: #fff;
line-height: 60px;
padding-left: 6px;
}
.el-dropdown {
color: #fff;
}
.logo-width {
width: 230px;
text-align: center;
border-color: hsla(62,77%,76%,.3);
border-right-width: 1px;
border-right-style: solid;
}
.userinfo {
text-align: right;
padding-right: 35px;
float: right;
}
.el-button--text {
color: inherit;
}
</style>
然后是main.js
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUi from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css' Vue.use(ElementUi) Vue.config.productionTip = false
// $router.path('/overview') /* eslint-disable no-new */
new Vue({
el: '#app',
router,
template: '<App/>',
components: { App }
})
router.js
import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/components/Home'
import Error from '@/components/404'
import overview from '@/components/overview/overview'
import instance from '@/components/instance/instance'
import backup from '@/components/instance/backup'
import recycleBin from '@/components/instance/recycleBin'
import keypairs from '@/components/instance/keypairs'
import capacityCalculation from '@/components/instance/capacityCalculation'
import ess_alarm from '@/components/ess/ess_alarm'
import ess_cluster from '@/components/ess/ess_cluster'
import ess_policy from '@/components/ess/ess_policy'
import ess_profile from '@/components/ess/ess_profile'
import ess_timer from '@/components/ess/ess_timer' Vue.use(Router); export default new Router({
routes: [
{
path: '/',
component: Home,
name: '',
iconCls: 'el-icon-message',
leaf: true,//只有一个节点
children: [
{ path: 'overview', component: overview, name: '云概览', mach: [] }
]
},
{
path: '/404',
name: '404',
component: Error,
hidden: true
},
{
path: '/',
component: Home,
name: '云主机',
iconCls: 'el-icon-message',//图标样式class
children: [
{ path: 'instance', component: instance, name: '云主机列表', mach: [] },
{ path: 'recycle_bin', component: recycleBin, name: '回收站', mach: [] },
{ path: 'capacity_calculation', component: capacityCalculation, name: '容量计算', mach: [] },
{ path: 'backup', component: backup, name: '备份', mach: [] },
{ path: 'keypairs', component: keypairs, name: '密钥对', mach: [] },
]
},
{
path: '/',
component: Home,
name: '弹性伸缩',
iconCls: 'el-icon-message',//图标样式class
children: [
{ path: 'ess_profile', component: ess_profile, name: '伸缩配置', mach: [] },
{ path: 'ess_policy', component: ess_policy, name: '伸缩规则', mach: [] },
{ path: 'ess_cluster', component: ess_cluster, name: '伸缩组', mach: [] },
{ path: '/', component: Home, name: '告警任务', mach: [
{ path: 'ess_timer', component: ess_timer, name: '定时伸缩'},
{ path: 'ess_alarm', component: ess_alarm, name: '告警伸缩'}
] }
]
},
]
})
vue + vue-router+vuex+elementUI开发环境搭建的更多相关文章
- vue前端+java后端 vue + vuex + koa2开发环境搭建及示例开发
vue + vuex + koa2开发环境搭建及示例开发 https://segmentfault.com/a/1190000012918518 vue前端+java后端 https://blog.c ...
- Electron+Vue+ElementUI开发环境搭建
Node环境搭建 本文假定你完成了nodejs的环境基础搭建: 镜像配置(暂时只配置node包镜像源,部分包的二进制镜像源后续讨论).全局以及缓存路径配置,全局路径加入到了环境变量 $ node -v ...
- vue学习【一、开发环境搭建】
一.安装node.js https://nodejs.org/en/ 建议安装LTS版本 安装完毕之后cmd命令查看node版本,如果不识别,记住设置环境变量 显示上面信息则安装成功 二.设置node ...
- windows下vue+webpack前端开发环境搭建及nginx部署
一.开发环境搭建 1.前端框架一般都依赖nodejs,我们首先要安装node.js.请参考http://www.cnblogs.com/wuac/p/6381819.html. 2.由于许多npm的源 ...
- windows下vue.js开发环境搭建教程
这篇文章主要为大家详细介绍了windows下vue.js开发环境搭建教程,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 最近,vue.js越来越火.在这样的大浪潮下,我也开始进入vue的学习行列中 ...
- vue开发环境搭建及热更新
写这篇博客的目的是让广大的学者在初入Vue项目的时候少走些弯路,虽然现在有很多博客也有差不多的内容,但是博主在里面添加了一些学习时碰到的小问题.在阅读这篇博客之前,我先给大家推荐一篇文章<入门W ...
- vue 开发系列(一) vue 开发环境搭建
概要 目前前端开发技术越来越像后台开发了,有一站式的解决方案. 1.JS包的依赖管理像MAVEN. 2.JS代码编译打包. 3.组件式的开发. vue 是一个前端的一站式的前端解决方案,从项目的初始化 ...
- express+mysql+vue开发环境搭建
最近开始做一个实验室资产管理系统,后台使用node.js的Express框架,前端使用vue,数据库使用mysql.在这里开始简单记录一下开发过程和遇到的问题. 今天要说的是express+mysql ...
- 最全Vue开发环境搭建
前言 一直想去学Vue,不过一直找不到一个契机.然公司手机端用到了跨平台开发apicloud,里边涉及到Vue组件化开发,例如header和footer的封装,以及apicloud自定义的frame等 ...
随机推荐
- 详解C#特性和反射(一)
使用特性(Attribute)可以将描述程序集的信息和描述程序集中任何类型和成员的信息添加到程序集的元数据和IL代码中,程序可以在运行时通过反射获取到这些信息: 一.通过直接或间接的继承自抽象类Sys ...
- Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name
启动apache的时候,报告以下消息提示: Starting httpd: httpd: Could not reliably determine the server's fully qualifi ...
- 微信公众号 几种移动端UI框架介绍
微信公众号开发,主要是移动端网页的页面开发,在这里推荐3个移动端UI框架:WeUI.SUI和Mint UI. 1. WeUI 1.1 WeUI WeUI是微信官方设计团队为微信 Web 开发量身设计, ...
- CentOS 7 下sendEmail发邮件失败,提示invalid SSL_version specified at /usr/share/perl5/vendor_perl/IO/Socket/SSL.pm line 415.
系统环境CentOS Linux release 7.2.1511 (Core) sendEmail发送邮件是出现以下报错:************************************** ...
- Atitit php vs node.js attilax总结
Atitit php vs node.js attilax总结 1.1. 上手度 还是php 1 1.2. Node.js最大的缺点 异步回调导致可读性差..特别嵌套的时候.. 1 1.1. 上手 ...
- ②NuPlayer播放框架之ALooper-AHandler-AMessage底层机制分析
[时间:2016-09] [状态:Open] [关键词:android,NuPlayer,开源播放器,播放框架,ALooper,AHandler,AMessage] 前文中提到过NuPlayer基于S ...
- 【iCore4 双核心板_ARM】例程二十一:LWIP_TCP_SERVER实验——以太网数据传输
实验现象: 核心代码: int main(void) { system_clock.initialize(); led.initialize(); adc.initialize(); delay.in ...
- Brainfuck解析器(Python)
global cs global ip global ss #global sp global ds global bp global tab global out cs='++++++++++[&g ...
- How to Catch Ctrl-C in Shell Script
ref: https://stackpointer.io/script/how-to-catch-ctrl-c-in-shell-script/248/ #!/bin/sh # this func ...
- .NET解决[Serializable] Attribute引发的Json序列化k_BackingField
在WebAPI中的WebApiConfig直接加入如下配置 有问题找谷歌