Vue实验三:属性、方法

一、实验目的
1、 属性的基本使用
2、 方法的基本使用
3、 侦听器的应用
4、 表单数据的绑定
5、 样式的绑定
二、实验内容
实现一个功能完整的用户注册页面

在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>实验3:属性、方法</title>
    <script src="vue.3.2.36.js"></script>
    <style>
        .container{
            text-align: center;
        }

        input{
            background-color: #fffa95;
            background-color: cornsilk;
            width: 300px;
            border-radius: 6px;
            height: 25px;
        }

        button{
            background-color: deepskyblue;
            height: 40px;
            width: 300px;
            border-color: blue;
            color: white;
            margin-top: 30px;
            border-radius: 10px;
        }
    </style>
</head> 
<body>
    <div class="container" id="app">
    <p>加入我们,一起创造美好世界</p>
    <h1>创建你的账号</h1>
    <div class="inputCon" v-for="(item,index) in items" >
        <p>{{item.title}}
            <span style="color:red;">*</span>
        </p>
        <input type="text" v-model="item.model"  name="inputlook">
        <p v-if="index==2">请确认密码程度需要大于6</p>
    </div>
    <div class="subCon">
        <p>偏好设置</p>
        <input type="checkbox" style="width:auto">接受更新邮件
        
    </div>
    <button @click="createAccount">创建账号</button>
    </div>
    <script>
        const App={
            data(){
                return{
                    items:[
                        {
                            title:'用户名',
                            model:''
                        },{
                            title:'邮箱地址',
                            model:''
                        },{
                            title:'密码',
                            model:''
                        }
                    ]
                }
            },
            computed:{
                name:{
                    get(){
                        return this.items[0].model
                    },
                    set(value){
                        this.items[0]=value
                    }
                },
                email:{
                    get(){
                        return this.items[1].model
                    },
                    set(value){
                        this.items[1]=value
                    }
                },
                password:{
                    get(){
                        return this.items[2].model
                    },
                    set(value){
                        this.items[2]=value
                    }
                }
            },
            methods:{
                createAccount(){
                 console.log(`name:${this.name}\npassword:${this.password}\nemail:${this.email}`)   
                }
                
            }
            
        }
        Vue.createApp(App).mount("#app");
    </script>

</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Yuexin️

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值