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

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

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

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


12345678_0001
浏览 110回答 2
2回答

素胚勾勒不出你

尝试这个 :)&nbsp; data() {&nbsp; &nbsp; &nbsp; &nbsp; return {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; form: {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; customer_email: "",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; },methods:{&nbsp; &nbsp; &nbsp;&nbsp;user(){axios.get("api/profile").then(({data})=>{(this.user = data)this.form.customer_emeail = this.user.email})},},created(){&nbsp; this.user();}在你的控制器中添加这个&nbsp; &nbsp;public function profile()&nbsp; &nbsp; {&nbsp; &nbsp; return auth('api')->user();&nbsp; &nbsp; }然后把它放在你的 api.php 中Route::get('profile','YourController@profile');

慕妹3146593

当你使用双向数据绑定时v-model,你可以简单地在 vue 端设置这个值。let app = new Vue({&nbsp; &nbsp; el:"#app",&nbsp; &nbsp; data() {&nbsp; &nbsp; &nbsp; &nbsp; return {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; form: {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; customer_email: "{{ auth()->user()->email }}",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ......&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ......&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; },&nbsp; &nbsp; ......&nbsp; &nbsp; ......});
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript