<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <div id="app"> <p>{{ foo }}</p> <!-- this will no longer update `foo`! --> <button v-on:click="foo = 'baz'">Change it</button> </div> <hr> <div id="example"> hello </div> <hr> <script> var obj = { foo: 'bar' } Object.freeze(obj) new Vue({ el: '#app', data: obj }) //------------------------ var data = { a: 1 } var vm = new Vue({ el: '#example', data: data }) vm.$data === data // => true vm.$el === document.getElementById('example') // => true // $watch is an instance method vm.$watch('a', function (newValue, oldValue) { console.log(newValue,oldValue) }) </script> </body> </html>
1-2 Vue Instance
最新推荐文章于 2025-03-31 16:13:54 发布