• Vue2+element-ui配置Register和404页面


    Vue2+element-ui配置Register和404页面

    安装element-ui

    $ cd client
    $ cnpm i element-ui -S
    
    • 1
    • 2

    main.js中引入element-ui:

    import Vue from 'vue'
    import App from './App.vue'
    import ElementUI from 'element-ui';
    import 'element-ui/lib/theme-chalk/index.css';
    
    import router from './router'
    import store from './store'
    
    Vue.config.productionTip = false
    Vue.use(ElementUI);
    
    new Vue({
      router,
      store,
      render: h => h(App)
    }).$mount('#app')
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16

    配置Register.vue

    创建client/src/views/Register.vue

    <template>
        <div class="register">
            <section class="form_container">
                <div class="manage_tip">
                    <span class="title">Kisu Management Platform</span>
                </div>
            </section>
        </div>
    </template>
    
    <scripts>
        export default {
        name: "register",
        components: {}
        };
    </scripts>
    
    <style scoped>
        .register {
            position: relative;
            width: 100%;
            height: 100%;
            background: url(../assets/bg.jpg) no-repeat center center;
            background-size: 100% 100%;
        }
        .form_container {
            width: 370px;
            height: 210px;
            position: absolute;
            top: 10%;
            left: 34%;
            padding: 25px;
            border-radius: 5px;
            text-align: center;
        }
    
        .form_container .manage_tip .title {
            font-family: "Microsoft YaHei";
            font-weight: bold;
            font-size: 26px;
            color: #fff;
        }
    </style>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43

    配置路由client/src/router/index.js

    import Vue from 'vue'
    import VueRouter from 'vue-router'
    import Index from '../views/Index.vue'
    import Register from '../views/Register.vue'
    
    Vue.use(VueRouter)
    
    const routes = [
      {
        path: '/',
        redirect: 'index'
      },
      {
        path: '/index',
        name: 'index',
        component: Index
        },
      {
          path: '/register',
          name: 'register',
          component: Register
      }
    ]
    
    const router = new VueRouter({
      mode: 'history',
      base: process.env.BASE_URL,
      routes
    })
    
    export default router
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31

    在浏览器中打开:

    http://localhost:8080/register
    
    • 1

    配置404.vue

    创建client/src/views/404.vue

    <template>
        <div class="notfound">
            <img src="../assets/404.webp" alt="">
        </div>
    </template>
    
    <style>
    .notfound{
        width: 100%;
        height: 100%;
        overflow: hidden;
    }
    .notfound img{
        width: 100%;
        height: 100%;
    }
    </style>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    配置路由client/src/router/index.js

    import Vue from 'vue'
    import VueRouter from 'vue-router'
    import Index from '../views/Index.vue'
    import Register from '../views/Register.vue'
    import NotFound from '../views/404.vue'
    
    Vue.use(VueRouter)
    
    const routes = [
      {
        path: '/',
        redirect: 'index'
      },
      {
        path: '/index',
        name: 'index',
        component: Index
        },
      {
          path: '/register',
          name: 'register',
          component: Register
        },
      {
          path: '*',
          name: '/404',
          component: NotFound
      }
    ]
    
    const router = new VueRouter({
      mode: 'history',
      base: process.env.BASE_URL,
      routes
    })
    
    export default router
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37

    在浏览器中打开:

    http://localhost:8080/registerxyy
    http://localhost:8080/lol23
    ...
    
    • 1
    • 2
    • 3
  • 相关阅读:
    C语言 深度探究C语言中的函数
    uniapp 如何发送formData数据请求(全网最佳解决方案)
    K8S集群中Coredns域名解析故障排查思路
    NoSQL之Redis配置与优化
    Spring整合Mybatis,SqlSessionTemplate方式
    C++中浅拷贝与深拷贝
    day57【动态规划】647.回文子串 516.最长回文子序列
    双指针算法
    17_方法
    MAC安装stable diffusion
  • 原文地址:https://blog.csdn.net/Sebastien23/article/details/125465866