zoukankan      html  css  js  c++  java
  • Vue-computed的set和get

    <!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>Document</title>
    </head>
    <body>
      <div id="app">
        {{fullName}}
        {{age}}
      </div>
    </body>
    <script type="text/javascript" src="./vue.js"></script>
    <script>
    var app=new Vue({
        el:'#app',
        data:{
          firstName:'li',
          lastName:'zhao',
          age:18
        },
        computed:{
          fullName:{
            get:function(){
              return this.firstName+' '+this.lastName
            },
            set:function(value){
              var arr = value.split(' ');
              this.firstName = arr[0];
              this.lastName = arr[1];
            },
          }
        }
    })
    </script>
    </html>
  • 相关阅读:
    JQuery hover鼠标变换
    装饰者模式
    principle04
    Method Injection
    观察者模式
    Java SPI
    Redis--学习01
    OO设计中5大原则
    knowledge
    策略模式
  • 原文地址:https://www.cnblogs.com/superlizhao/p/9621081.html
Copyright © 2011-2022 走看看