Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
haizhilin2013 opened this issue Jun 16, 2019 · 4 comments
Open

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

haizhilin2013 opened this issue Jun 16, 2019 · 4 comments
Labels
vue vue

Comments

@haizhilin2013
Copy link
Collaborator

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

@haizhilin2013 haizhilin2013 added the vue vue label Jun 16, 2019
@wenyejie
Copy link

有个参数immediate
https://cn.vuejs.org/v2/api/#vm-watch

@lancelote-zpc
Copy link

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

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

设置immediate属性为true

@crush2020
Copy link

选项:immediate

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

@yxllovewq
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vue vue
Projects
None yet
Development

No branches or pull requests

5 participants