• 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

            });

  • 相关阅读:
    自我分析和展望
    测试设计说明及结队反思总结
    WordCount项目
    结对编程
    第一周的博客作业
    第一次作业:统计文件字符串字符行的个数
    系统分析与设计结对项目———Wordcount
    第一周的博客作业
    第一次 作业 workcount (基础功能实现)
    触摸点为scrollview上的子控件时,scrollview不能滚动(iOS8)
  • 原文地址:https://www.cnblogs.com/macro-renzhansheng/p/13069637.html
Copyright © 2020-2023  润新知