Vue.js学习-8-watch监听对象简单学习
发布日期:2021-05-20 05:03:17 浏览次数:23 分类:原创文章

本文共 774 字,大约阅读时间需要 2 分钟。

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <title>Document</title>    <script src="https://unpkg.com/vue/dist/vue.js"></script></head><body>    <div id="vueApp">        <h1>打开控制台点击一下吧</h1>        <button v-on:click="change()">click</button>    </div></body><script>    let vueApp=new Vue({
el:"#vueApp", data:{
number:5 }, watch:{
number:function(newVal,oldVal){
console.log(newVal,oldVal); console.log("现在number发生了改变"); }, }, methods:{
change:function(){
this.number=100; } } } );</script></html>
上一篇:Vue.js学习-10-Vue.js计算属性set get 简单学习
下一篇:Vue.js学习-7-Vue.js计算属性computed简单学习

发表评论

最新留言

关注你微信了!
[***.104.42.241]2025年04月24日 16时19分23秒