• 067——VUE中vue-router之使用transition设置酷炫的路由组件过渡动画效果


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>vue-router之使用transition设置酷炫的路由组件过渡动画效果</title>
        <script src="vue.js"></script>
        <script src="node_modules/vue-router/dist/vue-router.js"></script>
        <link rel="stylesheet" href="animate.css">
    </head>
    <body>
    <div id="demo">
        <router-view></router-view>
    </div>
    <script type="text/x-template" id="home">
        <transition enter-active-class="animated rotateIn">
            <div>
                <li v-for="v in news">
    
                    <a href="#" @click.prevent="go(v.id)">{{v.title}}</a>
                </li>
            </div>
        </transition>
    </script>
    <script type="text/x-template" id="content">
        <transition enter-active-class="animated slideInDown">
            <div>
                <h1>{{field.title}}--{{field.id}}</h1>
                <p>
                    {{field.content}}
                </p>
                <a href="" @click.prevent="back()">返回首页</a>
            </div>
        </transition>
    </script>
    <script>
        const notFound = {
            template: '<h1>NotFound</h1>'
        }
        var data = [
            {id: 1, title: "php课程", content: "php是个比较牛的技术"},
            {id: 2, title: "java课程", content: "java是个比较牛的技术"},
            {id: 3, title: "pathon课程", content: "pathon是个比较牛的技术"}
        ]
        const home = {
            template: "#home",
            data() {
                return {
                    news: data
                }
            },
            methods: {
                go(id) {
                    //var url='/content/'+id; //url第一种写法
                    //var url={name:'content',params:{id:id}};//url第二种写法
                    //this.$router.replace(url);//replace()替换历史记录中的跳转:
    
                    var url = {'path': '/content/' + id};//跳转到详情页  //url第三种写法
                    this.$router.push(url);
                }
            }
        }
        const content = {
            template: "#content",
            data() {
                return {
                    field: {}
                }
            },
            mounted() {
                var id = this.$route.params.id;
                for (let k = 0; k < data.length; k++) {
                    if (data[k].id == id) {
                        this.field = data[k];
                    }
                }
            },
            methods: {
                back() {
                    this.$router.go(-1);
                }
            }
        }
        let routes = [
            {path: '/', component: home},
            {path: '/content/:id', component: content, name: "content"},
            {path: '/content/3', alias: ['/about']},
            {path: '*', component: notFound}
    
        ];
        //把组件交给路由器:
        let router = new VueRouter({routes});
        new Vue({
            el: "#demo",
            router
        });
    </script>
    </body>
    </html>
    

      

  • 相关阅读:
    WSS基础
    SPCAMLEditor1.0 publish
    关于代码调用SSP获取UserProfile出错的解决方案
    WSS Alert(邮件提醒) 定制
    MOSS字段编辑权限控制方案发布源码
    ListViewWebPart Code
    再议WSS RenderingTemplate
    Windows SharePoint Services Search和Office SharePoint Server Search的区别
    MOSS信息管理策略定制(MOSS custom policies)
    发布一个小工具SPCamlEditor
  • 原文地址:https://www.cnblogs.com/yiweiyihang/p/8353168.html
Copyright © 2020-2023  润新知