帮我用vue框架写两个页面,一个登录,一个注册,要有背景图片

时间: 2023-05-29 12:02:07 浏览: 39
由于您没有提供详细的需求和设计,以下是一个简单示例,您可以根据需要进行修改: 登录页面: ``` <template> <div class="login"> <img src="./login-bg.jpg" alt="login background" class="background"> <div class="content"> <h2>Login</h2> <form> <div class="form-group"> <label for="username">Username:</label> <input type="text" id="username" v-model="username" required> </div> <div class="form-group"> <label for="password">Password:</label> <input type="password" id="password" v-model="password" required> </div> <button type="submit" class="btn-login" @click.prevent="login">Log In</button> </form> </div> </div> </template> <script> export default { data() { return { username: '', password: '', }; }, methods: { login() { // TODO: 实现登录逻辑 }, }, }; </script> <style> .login { position: relative; width: 100%; height: 100vh; overflow: hidden; } .background { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } .content { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 1; padding: 20px; background-color: rgba(255, 255, 255, .7); border-radius: 5px; } h2 { margin-top: 0; margin-bottom: 20px; } form { display: flex; flex-direction: column; } .form-group { display: flex; flex-direction: column; margin-bottom: 10px; } label { margin-bottom: 5px; font-weight: bold; } input { padding: 5px; border: none; border-radius: 3px; font-size: 16px; } button.btn-login { margin-top: 20px; padding: 10px; background-color: #42b983; border: none; border-radius: 3px; color: #fff; font-size: 16px; cursor: pointer; } </style> ``` 注册页面: ``` <template> <div class="register"> <img src="./register-bg.jpg" alt="register background" class="background"> <div class="content"> <h2>Register</h2> <form> <div class="form-group"> <label for="username">Username:</label> <input type="text" id="username" v-model="username" required> </div> <div class="form-group"> <label for="password">Password:</label> <input type="password" id="password" v-model="password" required> </div> <div class="form-group"> <label for="confirmPassword">Confirm Password:</label> <input type="password" id="confirmPassword" v-model="confirmPassword" required> </div> <button type="submit" class="btn-register" @click.prevent="register">Register</button> </form> </div> </div> </template> <script> export default { data() { return { username: '', password: '', confirmPassword: '', }; }, methods: { register() { // TODO: 实现注册逻辑 }, }, }; </script> <style> .register { position: relative; width: 100%; height: 100vh; overflow: hidden; } .background { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } .content { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 1; padding: 20px; background-color: rgba(255, 255, 255, .7); border-radius: 5px; } h2 { margin-top: 0; margin-bottom: 20px; } form { display: flex; flex-direction: column; } .form-group { display: flex; flex-direction: column; margin-bottom: 10px; } label { margin-bottom: 5px; font-weight: bold; } input { padding: 5px; border: none; border-radius: 3px; font-size: 16px; } button.btn-register { margin-top: 20px; padding: 10px; background-color: #42b983; border: none; border-radius: 3px; color: #fff; font-size: 16px; cursor: pointer; } </style> ``` 注意:示例中使用了两个背景图片,需要提前准备好。背景图片应该放在页面的公共文件夹下,例如 `public` 文件夹,以便正确引用图片。也可以将图片放在组件对应的文件夹下,并使用相对路径引用,具体请根据实际情况进行调整。

相关推荐

最新推荐

recommend-type

解决vue多个路由共用一个页面的问题

下面小编就为大家分享一篇解决vue多个路由共用一个页面的问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
recommend-type

使用Vue组件实现一个简单弹窗效果

主要介绍了使用Vue组件实现一个简单弹窗效果,本文主要内容会涉及到弹窗遮罩的实现, slot 插槽的使用方式,props 、 $emit 传参,具体组件代码也传上去了。需要的朋友可以参考下
recommend-type

Vue 中 template 有且只能一个 root的原因解析(源码分析)

主要介绍了Vue 中 template 有且只能一个 root的原因解析,本文从源码角度分析给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
recommend-type

vue中阻止click事件冒泡,防止触发另一个事件的方法

下面小编就为大家分享一篇vue中阻止click事件冒泡,防止触发另一个事件的方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
recommend-type

基于vue写一个全局Message组件的实现

主要介绍了基于vue写一个全局Message组件的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

MATLAB取整函数与Web开发的作用:round、fix、floor、ceil在Web开发中的应用

![MATLAB取整函数与Web开发的作用:round、fix、floor、ceil在Web开发中的应用](https://img-blog.csdnimg.cn/2020050917173284.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2thbmdqaWVsZWFybmluZw==,size_16,color_FFFFFF,t_70) # 1. MATLAB取整函数概述** MATLAB取整函数是一组强大的工具,用于对数值进行
recommend-type

我想做python的算法工程师,我应该学什么?学习的顺序是什么?网上有什么推荐的免费课程吗?回答具体精确一点不要太笼统

对于想要成为 Python 算法工程师的人来说,他们应该先从掌握 Python 的基础语法开始,然后学习数据结构和算法,并且要深入了解 Python 中的一些科学计算和数据处理库,比如 NumPy、Pandas 等。 学习的顺序可以是先学习基础语法和编程技巧,然后再学习数据结构和算法相关的知识,最后深入了解数据处理和科学计算相关的库。 对于免费课程的推荐,我建议你可以先去 Coursera、edX、Udacity 等网站上寻找相关课程,这些网站上有很多优质的 Python 编程和算法课程,你可以根据自己的需求和学习进度进行选择。此外,还可以考虑一些在线编程网站,如 HackerRank、L
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。