vue+element UI--Container布局组件

1、基于 webpack 模板生成项目:
基于webpack模板生成项目地址
2、进入项目根目录安装Element UI:
命令:F:>cd F:\VUEworkspace\demo-project
在这里插入图片描述
3、修改/src/main.js文件,引入element-ui

// 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

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})

4、修改/src/router/index.js文件

import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/page/layout'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'Layout',
      component: Layout
    }
  ]
})

5、编辑/src/page/layout.vue

<template>
  <el-container>
    <el-header>Header</el-header>
    <el-container>
      <el-aside width="200px">Aside</el-aside>
      <el-main>Main</el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  name: 'App'
}
</script>

<style scoped>
.el-header {
  background-color: #B3C0D1;
  color: #333;
  text-align: center;
  line-height: 60px;
}
.el-aside {
  background-color: #D3DCE6;
  color: #333;
  text-align: center;
  line-height: 200px;
}
.el-main {
  background-color: #E9EEF3;
  color: #333;
  text-align: center;
  line-height: 160px;
}

</style>

Element UI Container 布局容器组件:

组件说明
el-container外层容器,当子元素中包含el-header或el-footer时,全部子元素会垂直上下排列,否则会水平左右排列
el-header顶栏容器
el-aside侧边栏容器
el-main主要区域容器
el-footer底栏容器

以上组件采用flex布局,使用前请确定目标浏览器是否兼容。
此外,el-container的子元素只能是后四者,后四者的父元素也只能是el-container。
6、启动服务npm run dev并预览
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,我会尽力用中文回答你的问题。 Vue Element UI 是一个基于 Vue.js 的前端 UI 组件库,可以帮助开发者快速构建 web 应用程序的用户界面。如果你想使用 Vue Element UI 编写登录界面,你可以这样做: 1. 安装 Vue Element UI:在你的 Vue.js 项目中使用 npm 或 yarn 安装 Vue Element UI。 ``` npm install element-ui ``` 2. 引入 Vue Element UI:在你的 Vue.js 项目的入口文件中引入 Vue Element UI 并注册组件。 ```javascript import Vue from 'vue' import ElementUI from 'element-ui' import 'element-ui/lib/theme-chalk/index.css' Vue.use(ElementUI) ``` 3. 创建登录界面:在你的 Vue.js 项目中创建一个登录界面的模板,使用 Vue Element UI 提供的组件来构建界面布局和样式。 ```html <template> <div class="login-container"> <el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form-item label="用户名" prop="username"> <el-input v-model="form.username" placeholder="请输入用户名"></el-input> </el-form-item> <el-form-item label="密码" prop="password"> <el-input v-model="form.password" type="password" placeholder="请输入密码"></el-input> </el-form-item> <el-form-item> <el-button type="primary" @click="handleLogin">登录</el-button> </el-form-item> </el-form> </div> </template> <script> export default { data() { return { form: { username: '', password: '' }, rules: { username: [ { required: true, message: '请输入用户名', trigger: 'blur' }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值