Vue.js 占位符不是vue前端的占位符

Vue.js 占位符不是vue前端的占位符,vue.js,vuetify.js,Vue.js,Vuetify.js,你好,我现在遇到了一个小问题,但很烦人 我正在尝试显示当前用户信息(不是密码或尚不可更新) 但是我的占位符应该使用的名称不显示,因为我在updateprofile中输入了我将在更改时更新的数据 有什么建议我可以这样做吗?还是帮忙 <v-text-field type="text" placeholder="user.fullname"

你好,我现在遇到了一个小问题,但很烦人

我正在尝试显示当前用户信息(不是密码或尚不可更新) 但是我的占位符应该使用的名称不显示,因为我在updateprofile中输入了我将在更改时更新的数据 有什么建议我可以这样做吗?还是帮忙

<v-text-field
                        type="text"
                        placeholder="user.fullname"
                        v-model="UpdateProfile.fullname"
                    ></v-text-field>
                    <v-text-field
                        
                        type="email"
                        v-model="email"
                        placeholder="$user.email"
                    > </v-text-field>

配置文件上的整个代码

<template>
    <v-container>
        <div class="col-md-5 col-sm-12 mx-auto">
            <v-card
                class="pa-5"
                elevation="3"
            >
                <v-form class="col-12 pa-0"> 
                    <h2 class="text-center">Profile Page {{ fullname }}</h2>
                    
                    <v-text-field
                        type="text"
                        placeholder="user.fullname"
                        v-model="UpdateProfile.fullname"
                    ></v-text-field>
                    <v-text-field
                        
                        type="email"
                        v-model="email"
                        placeholder="$user.email"
                    > </v-text-field>
                    
                    <v-text-field
                        
                        type="text"
                        v-model="phone"
                        placeholder="$user.phone"
                    > </v-text-field>
                        
                    <v-text-field
                        label="New password?"
                        type="password"
                       
                        class="pr-2"
                    > </v-text-field>

                    <v-text-field
                        label="Reapeat password"
                        type="password"
                       
                        class="pr-2"
                    > </v-text-field>

                    <div class="row ma-0">
                        <v-text-field
                            
                            type="text"
                            v-model="address.street"
                            class="pr-2"
                            placeholder="$user.street"
                        > </v-text-field>

                        <v-text-field
                            
                            type="text"
                            v-model="address.number"
                            placeholder="$user.address.number"
                        > </v-text-field>
                    </div>

                    <div class="row ma-0">
                        <v-text-field
                            
                            type="number"
                            v-model="address.zip"
                            class="pr-2"
                            placeholder="$user.address.zip"
                        > </v-text-field>

                        <v-text-field
                            
                            type="text"
                            v-model="address.city"
                            placeholder="$user.address.city"
                        > </v-text-field>
                    </div>

                    <v-btn
                        block
                        color="primary"
                        v-on:click="onUpdateProfile()"
                    >
                        Update userinfo
                    </v-btn>
                </v-form>
            </v-card>
        </div>
        
    </v-container>
</template>

<script>
export default{
    data() {
        return {
            email: null,
            fullname: null,
            password: null,
            phone: null,
            address: {
                street: null,
                number: null,
                zip: null,
                city: null
            },

            UpdateProfile:{
            email: "",
            fullname: "",
            password: "",
            phone: "",
            address: {
                street: "",
                number: "",
                zip: "",
                city: ""
            } 
            }
        };
    },
    

    mounted: function() {
        this.axios.post('http://localhost:3000/auth', null, { 
            headers: { 
                jwt: this.$cookies.get('jwt'),
            }
        })
        .then((res) =>{
            console.log(res)
            this.fullname = res.data.user.fullname;
            this.email = res.data.user.email;
            // this.password = res.data.user.password;
            this.phone = res.data.user.phone;
            this.address = res.data.user.address;
            

        }).catch(err => {
            console.log(err);
            this.$router.push('/*');
        });
                        
        
    },
    

    methods: {
        onUpdateProfile: function() {
            // Validere om passwords matcher
                // if(this.register.password != this.register.confirmPassword) {
                //     this.error = "Passwords matcher ikke";
                //     this.loading = false;
                //     return;
                // }

            // Send post request om at update brugeren
            this.axios.post('http://localhost:3000/update', {user: this.UpdateProfile}, { 
            headers: { 
                jwt: this.$cookies.get('jwt'),
            }
            })
            .then((res) => {
                console.log(res)
                this.$router.push('/dashboard');
            }).catch(err => {
                // Fejled respons
                console.log(err);
                this.$router.push('/*');
            });
            
        },
        
    }
}

</script>
<style>
</style>
                   

配置文件页{{fullname}
更新用户信息
导出默认值{
数据(){
返回{
电子邮件:空,
全名:null,
密码:null,
电话:空,
地址:{
街道:空,
编号:空,
zip:null,
城市:空
},
更新配置文件:{
电邮:“,
全名:“,
密码:“”,
电话:“,
地址:{
街道:“,
编号:“,
邮政编码:“,
城市:“
} 
}
};
},
挂载:函数(){
此.axios.post('http://localhost:3000/auth“,空,{
标题:{
jwt:this.$cookies.get('jwt'),
}
})
。然后((res)=>{
console.log(res)
this.fullname=res.data.user.fullname;
this.email=res.data.user.email;
//this.password=res.data.user.password;
this.phone=res.data.user.phone;
this.address=res.data.user.address;
}).catch(错误=>{
控制台日志(err);
这是.$router.push('/*');
});
},
方法:{
onUpdate配置文件:函数(){
//Validere om密码匹配器
//if(this.register.password!=this.register.confirmPassword){
//this.error=“密码匹配器ikke”;
//这一点:加载=错误;
//返回;
// }
//在更新brugeren时发送post请求om
此.axios.post('http://localhost:3000/update“,{user:this.UpdateProfile},{
标题:{
jwt:this.$cookies.get('jwt'),
}
})
。然后((res)=>{
console.log(res)
这个.$router.push('/dashboard');
}).catch(错误=>{
//Fejled响应
控制台日志(err);
这是.$router.push('/*');
});
},
}
}
代码是有效的,但是我不知道如何同时实现这两个功能来显示和更改,帮助

在HTML中,属性(
name=”“
)将始终是
字符串

在Vue中,绑定(
:name=”“
)将始终是JavaScript

因此,您可能正在查找
:placeholder=“user.fullname”

或者,如果
user.fullname
未定义,则可以使用条件回退:

:placeholder=“user.fullname?user.fullname:“全名”