该代码用于创建个人资料编辑页面,用户可以在其中更新个人信息,例如姓名、出生日期和密码。
该代码提供以下基本功能:
<form action="#">
<div class="grid grid-cols-1 gap-4">
<div>
<label for="name" class="text-gray-700 font-medium block mb-2">Name</label>
<input
type="text"
id="name"
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white"
placeholder="Samuel Fletcher"
required
/>
</div>
<div>
<label for="dob" class="text-gray-700 font-medium block mb-2">Date of Birth</label>
<input
type="date"
id="dob"
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white"
placeholder="14-03-1990"
required
/>
</div>
<div>
<label for="password" class="text-gray-700 font-medium block mb-2">Password</label>
<input
type="password"
id="password"
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white"
placeholder="********"
required
/>
</div>
</div>
<div class="mt-4">
<button
type="submit"
class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center mr-2 mb-2 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
>
Update Changes
</button>
</div>
</form>
import { ref } from "vue";
const name = ref("Samuel Fletcher");
const dob = ref("14-03-1990");
const password = ref("********");
const updateProfile = () => {
// API call to update profile
console.log("Profile updated!");
};
<form action="#">
<!-- ... -->
<div class="mt-4">
<button
type="submit"
@click="updateProfile"
class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center mr-2 mb-2 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
>
Update Changes
</button>
</div>
</form>