账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    vue监听父组件传过来的数组不起作用,如何解决?
    58
    0

    parent-components:

     <div class="item-bottom" v-show="course.showLesson">
        <CourseLesson :lessons="course.name"/>
    </div>
    
    ...
    getCourses(){
                console.log('user=',this.user)
                let studentId = this.user.student.id;
                this.$fetch(`${this.$url}/order/queryByStudentId`,{
                    params:{
                        studentId:studentId
                    }
                })
                .then(res=>{
                    let res_data = res.data;
                    console.log('get:/order/queryByStudentId:res_data',res_data);
                    if(res_data.success){
                        let orders = res_data.data;
                        orders.forEach(order=>{
                            let orderItem = order.orderItem;
                            let course = orderItem.course;
                            course.noUsedLessonCount = 0;
                            course.usedLessonCount = 0;
                            course.showLesson = false;
                            this.courses.push(course);
    ...

    CourseLesson:

        props:{
            lessons:{
                type:Array,
                default:()=>{
                    return []
                }
            }
        },
        watch:{
            lessons(newVal,oldVal){
                alert(1)
                newValue.forEach(lesson=>{
                    lesson.showDetail = false;
                })
                console.log('newvalue',newValue)
            }
        },

    我在watch里面添加了alert(1),但是根本 就没弹出,可是列表是成功渲染的,这是 为什么?

    0
    打赏
    收藏
    点击回答
        全部回答
    • 共 0 条
    • 锁顁婞福 普通会员 1楼
      502 Bad Gateway

      502 Bad Gateway


      nginx
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部