首页 > 解决方案 > 如何设置使用 v-model 的值输入?- 拉拉维尔

问题描述

如何设置使用 v-model 的值输入?我用谷歌搜索了这个问题,但没有解决我有这样的输入:

<input type="text" name="customer_email" v-model="form.customer_email" id="email">

我需要将此输入值设置为{{ auth()->user()->email }}

标签: javascriptlaravelvue.js

解决方案


试试这个 :)

  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');

推荐阅读