插件出口中的用户字段不起作用

我正在尝试将此用户字段 user-fields/5 添加到此出口 above-user-summary-stats。但它没有加载,这是我尝试使用的 hbs:

{{!-- Display and edit a custom user field (e.g., "profile note") for user_field_5 --}}
{{#if this.fieldValue}}
  <div>
    <strong>Profile Note:</strong> {{this.fieldValue}}
  </div>
{{else}}
  {{#if this.canEdit}}
    <div class="profile-note-display empty">
      <em>No profile note set</em>
    </div>
  {{/if}}
{{/if}}

{{#if this.canEdit}}
  {{#unless this.editing}}
    <button class="btn btn-primary btn-small" {{on "click" this.startEdit}}>
      {{#if this.fieldValue}}Edit{{else}}Add{{/if}} Profile Note
    </button>
  {{/unless}}
{{/if}}

{{#if this.editing}}
  <form {{on "submit" this.save}}>
    <textarea
      rows="4"
      style="width:100%;"
      value={{this.editValue}}
      {{on "input" this.updateEdit}}
      autofocus
    ></textarea>
    <br>
    <button type="submit" class="btn btn-primary btn-small">Save</button>
    <button type="button" class="btn btn-conditional btn-small" {{on "click" this.cancelEdit}}>Cancel</button>
  </form>
{{/if}}

可能是什么问题?

1 个赞

仅凭此模板,我认为我们没有足够的信息来提供帮助。this.fieldValue 是如何定义的?

如果您在站点设置 Public user custom fields 中输入 user_field_5……您应该可以通过此插件出口访问它

在您的模板中,如:{{@user.custom_fields.user_field_5}}

或者在您的 JS 中,如:this.args.user?.custom_fields?.user_field_5

1 个赞