zoukankan      html  css  js  c++  java
  • Vue 组件的使用

    1、引入组件

    import Week from '../week/main.vue'
    
    export default {
        name: "classMain",
        components: {
            Week: Week
        },
        data(){
            return {
                schoolID: this.$route.params.id,//学校 id
                portType: "incalss",//incalss,beike,iphone
                isShowChildPages: false
            }
        },
        methods: {
            showChildPage: function () {
                this.isShowChildPages = true;
            },
            closeChildPage: function (data) {
                console.log(data);
                this.isShowChildPages = false;
            },
        }
    } 

    2、显示组件

    <transition name="fade1">
      <Week v-if="isShowChildPages" :portType="portType" @closeChildPage="closeChildPage"></Week>
    </transition>

    3、组件接受参数,并调用父级方法

    export default {
        name: 'weekMain',
        watch: {
            //如果路由发生了变化,更新页面数据
            $route(to, from) {
                if (to.path !== from.path) {
                    this.schoolID = this.$route.params.id;
                }
            }
        },
        props: {
            portType: {
                type: String,
                default: () => {
                    return ''
                }
            }
        },
        data () {
            return {
                schoolID: this.$route.params.id,//学校 id
            }
        },
        methods: {
         //重点 closeChildPage:
    function () { this.$emit('closeChildPage', false); } } }
  • 相关阅读:
    instanceof操作符判断对象类型
    继承
    题解 P3943 星空
    NOIP 模拟 10 考试总结
    题解 P3942 将军令
    题解 P3941 入阵曲
    题解 P3191 [HNOI2007]紧急疏散EVACUATE
    NOIP 模拟 9 考试总结
    NOIP 模拟 9 分组
    NOIP 模拟 9 数颜色
  • 原文地址:https://www.cnblogs.com/sanqianjin/p/10767192.html
Copyright © 2011-2022 走看看