<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>vue 入门</title> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <div id="app"> 姓 <input type="text" v-model=‘firstname‘> 名 <input type="text" v-model="lastname"> <span>{{ fullName }}</span> <span>{{ count }} </span> </div> <script> new Vue({ el:"#app", data:{ firstname:‘‘, lastname:‘‘, count:0 }, computed:{ fullName (){ return this.firstname + this.lastname } }, watch:{ fullName:function(){ this.count++ } } }) </script> </body> </html>
原文地址:https://www.cnblogs.com/php-linux/p/11617214.html
时间: 2024-11-05 23:29:14