Skip to content

[vue] 怎么在watch监听开始之后立即被调用? #266

Open
@haizhilin2013

Description

@haizhilin2013
Collaborator

[vue] 怎么在watch监听开始之后立即被调用?

Activity

wenyejie

wenyejie commented on Jun 17, 2019

@wenyejie
lancelote-zpc

lancelote-zpc commented on Mar 18, 2020

@lancelote-zpc
  let vm=new Vue({
        el:"#first",
        data:{msg:'liuneng'},
        watch:{

            msg:{
                handler (newMsg,oldMsg){
                    console.log(newMsg);
                },
                immediate:true
            }
        }
    })

设置immediate属性为true

crush2020

crush2020 commented on Feb 2, 2021

@crush2020

选项:immediate

在选项参数中指定 immediate: true 将立即以表达式的当前值触发回调

yxllovewq

yxllovewq commented on Mar 9, 2022

@yxllovewq

直接添加watch.监听对象.immediate = true就ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @wenyejie@haizhilin2013@lancelote-zpc@crush2020@yxllovewq

        Issue actions

          [vue] 怎么在watch监听开始之后立即被调用? · Issue #266 · haizlin/fe-interview