admin管理员组

文章数量:1122846

I have problems with 11ty and alpineJs. I have input and its type is number. When I removed everything from the input, the value changed to null (just null). Please help me if you can solve it

for this I set value, defaultValue, default and everything else I Just don't want fix it in Js and I need to solve it in html I was doing everything but I don't have a solution for it. use my input as a component

{% macro unitNumberField(params) %}
<div
  class="inline-flex flex-row items-center gap-2 rounded-md border border-onSecondaryContainer border-opacity-10 shadow-sm pe-4 focus-within:outline focus-within:outline-2 focus-within:outline-tertiary focus-within:border-none focus-within:shadow-none"
  {% if params.invalidHandler %}:class="{'!border-error focus-within:!outline-error': {{ params.invalidHandler }}}"{% endif %}
>
  <input
    type="number"
    dir="ltr"
    {% if params.model %}x-model.number="{{ params.model }}"{% endif %}
    {% if params.onInput %}@input.debounce.250ms="{{ params.onInput }}"{% endif %}
    placeholder="{{ params.placeholder }}"
    class="peer bg-transparent inline-block ps-4 h-10 rounded-md border-none !shadow-none hide-spin focus-visible:outline-none {{ params.customInputClass }}"
    autocomplete="{{ params.autocomplete | default('off') }}"
    value="{{ params.value }}"
    min="{{ params.min | default(0) }}"
  />
  <span
    class="opacity-80 {{ params.customUnitClass }}"
    {% if params.dynamicUnitContent %}
      x-text="{{ params.dynamicUnitContent }}"
    {% endif %}
  >
    {{ params.unitContent | safe }}
  </span>
</div>
{% endmacro %}

本文标签: htmlset null value for my model with 11ty and alpineJSStack Overflow