<template>
<div>
<input placeholder="请输入账号" v-model="phone"></input>
<input placeholder="请输入密码" v-model="password"></input>
<button :disabled="loginBtn" @click="login">登录</button>
</div>
</template>
<script setup lang="ts">
import {ref, computed} from "vue"
const phone = ref ('')
const password = ref ('')
const loginBtn = computed (() => {
return !phone.value || !password.value
})
// 登录
const login = () => {
if (loginBtn.value){
return
};
// ...
}
</script>
所有表单未输入内容时 按钮禁用
最新推荐文章于 2024-09-30 15:42:36 发布