【问题标题】:show Authenticated user in select option vuejs在选择选项 vuejs 中显示经过身份验证的用户
【发布时间】:2021-07-06 16:51:47
【问题描述】:

我有一个表单,我想用一些用户填写选择选项,如果选项 id 等于登录用户,那么它将设置为选定选项。

<div class="flex flex-col mb-4 md:w-full">
    <label for="seller_id">Vendedor</label>
    <select v-model="registration.seller_id" name="seller_id">
          <option disabled>Vendedor</option>
          <option v-for="seller in sellers" :key="seller" :value="seller.id" v-bind:selected="seller.id == this.$page.props.user.id">{{ seller.name }}</option>
    </select>
</div>

这是脚本

<script>
export default {
props: {
    sellers: {
        type: Array,
        required: true
    },
},
data() {
    return {
        step:1,
        showModal: false,
        registration:{
            seller_id: null,
            name:null,
            email:null,
            rg:null,
            cpf:null,
            rural_productor_code:null,
            birthday:null,
            street:null,
            city:null,
            state:null,
        }
    }
   },
};
</script>

当我打印选项内的条件时,它显示为真,但当前用户未被选中。

【问题讨论】:

    标签: laravel-8 vuejs3 inertiajs


    【解决方案1】:

    这取决于您将当前用户状态保存在何处。开

    created() {
    // You assign your logged Seller Id or null if no user signed in
    this.registration.seller_id = yourLoggedUser.id || null
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-23
      • 2018-05-12
      • 2018-12-09
      • 1970-01-01
      • 2012-04-13
      • 2022-12-04
      • 1970-01-01
      • 2020-11-15
      相关资源
      最近更新 更多