【发布时间】:2018-04-06 06:58:42
【问题描述】:
我试图尽可能远离 Spark 的 Vue 组件,但我发现我必须实现某些邮件设置,所以我不能再坚持太久了。
幸运的是,Spark 文档包含一个用于添加配置文件字段的小食谱: https://spark.laravel.com/docs/4.0/adding-profile-fields
大部分部分都在我的(有限的 PHP)舒适区内:
先刀片php:
邮件设置
<div class="col-md-6">
<label class="radio-inline"><input type="radio" value="profile" v-model="form.type" name="profile">Profile</label>
<label class="radio-inline"><input type="radio" value="website" v-model="form.type" name="website">Website</label>
<label class="radio-inline"><input type="radio" value="combined" v-model="form.type" name="combined">Combined</label>
<span class="help-block" v-show="form.errors.has('mail-settings')">
@{{ form.errors.get('mail-settings') }}
</span>
</div>
</div>
集成:
<!-- Update Mail settings -->
@include('settings.profile.update-mail-settings')
从前面的代码块可以看出,我希望存储 3 个单选按钮的结果。 但是链接的 Vue js 文件让我很头疼:
Vue.component('update-mail-settings', {
props: ['user'],
data() {
return {
form: new SparkForm({
profile: ''
website: ''
combined: ''
})
};
},
mounted() {
this.form.mailsettings = this.user.mailsettings;
},
methods: {
update() {
Spark.put('/settings/profile/mail-settings', this.form)
.then(response => {
Bus.$emit('updateUser');
});
}
}
});
但是我到底如何将单选按钮集成到 SparkForm 中?
【问题讨论】:
标签: vue.js vue-component laravel-spark