vue中的computed用法
作者:互联网
<template>
<div>
<input v-model="first"></input>
<input v-model="second"></input>
<input v-model="action"></input>
</div>
</template>
<script> // import { set } from 'js-cookie'
export default { data() { return { 'first': 'tom', 'second': 'eat' // 'action': '' } }, computed: { action: { get() { return this.first + '-' + this.second }, set(val) { this.first = val.split('-')[0] this.second = val.split('-')[1] } } } }
</script>
<script> // import { set } from 'js-cookie'
export default { data() { return { 'first': 'tom', 'second': 'eat' // 'action': '' } }, computed: { action: { get() { return this.first + '-' + this.second }, set(val) { this.first = val.split('-')[0] this.second = val.split('-')[1] } } } }
</script>
标签:vue,return,computed,val,用法,second,set,first 来源: https://www.cnblogs.com/rain124/p/16479187.html