为了账号安全,请及时绑定邮箱和手机立即绑定

如何设置使用 v 模型的值输入?- 拉拉维尔

如何设置使用 v 模型的值输入?- 拉拉维尔

12345678_0001 2023-03-18 16:28:01

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

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

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


查看完整描述

2 回答

?
素胚勾勒不出你

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


查看完整回答
反对 回复 3天前
?
慕妹3146593

TA贡献1610条经验 获得超9个赞

当你使用双向数据绑定时v-model,你可以简单地在 vue 端设置这个值。


let app = new Vue({

    el:"#app",

    data() {

        return {

            form: {

                customer_email: "{{ auth()->user()->email }}",

                ......

                ......

            }

        }

    },

    ......

    ......

});


查看完整回答
反对 回复 3天前
  • 2 回答
  • 0 关注
  • 10 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信