1024

4、Vue3 computed计算属性

2020-12-31  本文已影响0人  圆梦人生

案例

<template>
    <div>
        {{cmpfun}} <br>
        <input @input="inputFun" type="number"/>
    </div>
</template>
<script>
import { computed, ref } from 'vue'
export default {
    name: 'index3',
    setup(){
        const args1 = ref(0);
        // 计算属性
        const cmpfun = computed(()=>{
            return `args1 == ${args1.value} `
        })
        const inputFun = (e)=>{
            //
            args1.value = e.target.value || 1
        }
        return { args1, inputFun, cmpfun }
    }
}
</script>
上一篇下一篇

猜你喜欢

热点阅读