zoukankan      html  css  js  c++  java
  • Vue:XXX后台管理系统

    【1】页面布局

    <div id="app">

    <router-view></router-view>

    </div>

    【2】组件定义

    ==================根组件==================

    const App = {

    template: `

                <div>

                    <header>XXX后台管理系统</header>

                    <main>

                        <div class="nav left">

                            <ul>

                               <!-- 设置路由 -->

                                <li>

                                    <router-link to="/users">用户管理</router-link>

                                </li>

                                <li>

                                    <router-link to="/goods">商品管理</router-link>

                                </li>

                                <li>

                                    <router-link to="/rights">权限管理</router-link>

                                </li>

                                <li>

                                    <router-link to="/orders">订单管理</router-link>

                                </li>

                            </ul>

                        </div>

                        <div class="content right">

                            <router-view></router-view>

                        </div>

                    </main>

                    <footer>*****公司版权所有*****</footer>

                </div>

                `

            };

    ==================子组件组件==================

    ===============用户组件==============

    const Users = {

    template: `

                <div>

                    <h2>用户管理</h2>

                    <table>

                        <thead>

                            <tr>

                                <th>用户编号</th>

                                <th>用户姓名</th>

                                <th>用户年龄</th>

                                <th>操作</th>

                            </tr>

                        </thead>

                        <tbody>

                            <tr v-for="user in userlist" :key="user.id">

                                <td>{{user.id}}</td>

                                <td>{{user.name}}</td>

                                <td>{{user.age}}</td>

                                <td>

                                    <a href="javascript:;" @click="goDetai(user.id)">查看详情</a>

                                </td>

                            </tr>

                        </tbody>

                    </table>

                </div>

                `,

    data() {

    return {

    userlist: [{

    id: 1,

    name: 'zs',

    age: 20

                        }, {

    id: 2,

    name: 'ls',

    age: 20

                        }, {

    id: 3,

    name: 'ww',

    age: 20

                        }]

                    }

                },

    methods: {

    goDetai(id) {

    //push跳转组件

    this.$router.push(`/userinfo/${id}`);

                    }

                }

            };

    //users 进一步组件

    const UserDetail = {

    props: ['id'],

    template: `

                    <div>

                        <h2>用户详情:该用户id为{{id}}</h2>   

                    </div>

                `

            }

    ================权限、产品、订单组件简单定义============

    const Rights = {

    template: `

                    <h3>权限管理区</h3>

                `

            }

    const Products = {

    template: `

                <h3>产品管理区</h3>

                `

            }

    const Orders = {

    template: `

                <h3>订单管理区</h3>

                `

            }

    【3】路由规则定义

    const router = new VueRouter({

    routes: [{

    path: '/',

    component: App,

    redirect: '/users',

    children: [{

    path: '/users',

    component: Users

                    }, {

    path: '/rights',

    component: Rights

                    }, {

    path: '/goods',

    component: Products

                    }, {

    path: '/orders',

    component: Orders

                    }, {

    path: '/userinfo/:id',

    component: UserDetail,

    props: true

                    }]

                }]

            });

    //挂载路由

    const vm = new Vue({

    el: '#app',

    router

            });

  • 相关阅读:
    IO操作之BIO、NIO、AIO
    IO之Socket网络编程
    this.getClass()和super.getClass()得到的是同一个类
    经济增长的背后
    SVN分支创建与合并
    .net类库里ListView的一个BUG
    VS2010调试技巧
    用C#代码编写的SN快速输入工具
    请教如何改善C#中socket通信机客户端程序的健壮性
    利用WebClient实现对Http协议的Post和Get对网站进行模拟登陆和浏览
  • 原文地址:https://www.cnblogs.com/macro-renzhansheng/p/13069637.html
Copyright © 2011-2022 走看看