首页 > 解决方案 > 在firebase + Vue + Quasar中更改个人资料图片之前为用户设置默认图像

问题描述

我正在开发一个学生、教职员工和非教职员工可以访问的学校应用程序,我如何在 img src 中添加一个功能,为用户提供默认的个人资料图片,这样我创建的每个新用户都不会有空白图片来源

我的模板如下所示:

<q-avatar size="150px" class="q-mb-sm">
  <q-img :loading="loading" :src="userDetails.image" />
</q-avatar>

我的州

email:"opeyemi@gmail.com"
image:undefined
name:"Opeyemi"
select:"Student"
userId:"4arS2LtESXb9u5uRjXcJl9u9prP2"

当然图像将返回未定义,我如何为新用户提交默认个人资料图片

我如何注册我的用户

registerUsers({}, payload) {
    firebaseAuth.createUserWithEmailAndPassword(payload.email, payload.password)
      .then(res => {
        const userId = res.user.uid;
        console.log(res)
        Notify.create({
          message: 'Regsitration Successful!.',
          color: 'positive',
          classes: 'quick'
        })
        //set user
        firebaseDb.ref(`users/${userId}`).set({
          name: payload.name,
          email: payload.email,
          select: payload.select
        });
      })
      .catch(err => {
        console.log(err)
        Notify.create({
          message: `${err.message}`,
          classes: 'quick',
          color: 'negative'
        })
      })

    console.log(payload)

标签: vuejs2firebase-storagevuex

解决方案


推荐阅读