如何设置使用 v 模型的值输入?我用谷歌搜索了这个问题但没有解决我有这样的输入:
<input type="text" name="customer_email" v-model="form.customer_email" id="email">
我需要将此输入值设置为{{ auth()->user()->email }}
如何设置使用 v 模型的值输入?我用谷歌搜索了这个问题但没有解决我有这样的输入:
<input type="text" name="customer_email" v-model="form.customer_email" id="email">
我需要将此输入值设置为{{ auth()->user()->email }}
TA贡献1590条经验 获得超9个赞
尝试这个 :)
data() {
return {
form: {
customer_email: "",
}
}
},methods:{
user(){
axios.get("api/profile").then(({data})=>{
(this.user = data)
this.form.customer_emeail = this.user.email
})
},
},created(){
this.user();
}
在你的控制器中添加这个
public function profile()
{
return auth('api')->user();
}
然后把它放在你的 api.php 中
Route::get('profile','YourController@profile');
TA贡献1610条经验 获得超9个赞
当你使用双向数据绑定时v-model,你可以简单地在 vue 端设置这个值。
let app = new Vue({
el:"#app",
data() {
return {
form: {
customer_email: "{{ auth()->user()->email }}",
......
......
}
}
},
......
......
});
举报