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

            });

  • 相关阅读:
    mvc
    拦截器
    使用HttpWebRequest和HtmlAgilityPack抓取网页(拒绝乱码,拒绝正则表达式)
    编译和解释的区别是什么?
    15 个最佳的 jQuery 表格插件
    编程小白必备——主流语言C语言知识点
    妹子找你修电脑,按照这几步操作,你就是黑客大佬!
    网络管理监视很重要!学编程的你知道哪些不错的网络监控工具?2020 最好的Linux网络监控工具分享给你
    为什么程序员要跳槽,钱并非第一位
    代码编写行为准则,编码是一个认真思考的过程,如何有效提高代码的可读性?
  • 原文地址:https://www.cnblogs.com/macro-renzhansheng/p/13069637.html
Copyright © 2011-2022 走看看