<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="../vue-dev/vue-dev/dist/vue.min.js"></script> <script src="vue-router.js"></script> </head> <body> <div id="app"> <input type="text" v-model="firstname" >+ <input type="text" v-model="lastname" >= <input type="text" v-model="fullname" > </div> <script> var vm = new Vue({ el:"#app", data:{ firstname:"", lastname:"", }, methods:{ }, computed:{ "fullname":function () { return this.fullname = this.firstname + '-' + this.lastname } } }) </script> </body> </html>
computed计算属性的使用
最新推荐文章于 2024-07-16 09:46:43 发布