computed

computed 计算属性(派生值,附加值)

基于原来的属性,对数据进行处理,不改变原数据

    let myInput = {
        template:`  <div>
                        <input v-model="msg">
                        <br>
                        <span>{{changeMsg}}</span>
                    </div>`,
        data() {
            return {
                msg:'hello'
            }
        },
        computed:{
            changeMsg() {
                return this.msg.split('').join()
            }
        }
    }
    new Vue({
        el: "#app",
        components:{
            myInput
        }
    })
 

 

posted @ 2018-07-30 19:37  Goff956  阅读(230)  评论(0编辑  收藏  举报