【问题标题】:how to pass a dynamic value from input field to progress prop of vue-circle component如何将输入字段中的动态值传递给vue-circle组件的progress prop
【发布时间】:2020-06-23 13:31:46
【问题描述】:

我正在使用 vue-circle 来显示用户将输入字段的 throw v-modal 传递给 vue-circle 组件的技能和技能级别,但是当我输入值时,我不断收到此错误80:

[Vue warn]: Invalid prop: type check failed for prop "progress". Expected Number with value 80, got String with value "80".

这就是我传递值的方式:

<vue-circle
      v-for="(skill, index) in skills"
      :key="index"
      :progress= "skill.level"
      :size="130"
      :reverse="false"
      line-cap="round"
      :fill="fill"
      empty-fill="rgba(0, 0, 0, .3)"
      :animation-start-value="0.0"
      :start-angle="0"
      insert-mode="append"
      :thickness="12"
      :show-percent="false"
    >
     <span>{{ skill.skillName }}</span>
</vue-circle>

这是我输入数据的输入:

<div class="form-row" v-for="(skill, i) in skills" :key="i">
     <div class="form-group col-md-7">
                <label for="skill">skill</label>
                <input
                type="text"
                class="form-control"
                id="skill"
                placeholder="Skill"
                v-model.lazy="skill.skillName"
              />
            </div>
            <div class="form-group col-md-5">
              <label for="languageLevel">Level</label>
              <input
                type="text"
                pattern="\d*"
                minlength="2"
                maxlength="3"
                class="form-control"
                id="skillLevel"
                placeholder="Skill Level"
                v-model="skill.level"
              />

【问题讨论】:

    标签: javascript vue.js


    【解决方案1】:

    尝试使用输入 type="number",问题是 type="text" 正在返回,但字符串 progress prob 需要一个数字。或者您仍然可以使用 parseInt(string, radix) 方法将值转换为数字

    【讨论】:

    • 当你这样做时,你仍然收到,但这个错误 [Vue 警告]:无效的道具:道具“进度”的类型检查失败。预期值为 80 的数字,得到值为“80”的字符串。?
    • 我不明白你的意思
    猜你喜欢
    • 2021-11-02
    • 2017-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-09
    • 2019-02-23
    • 2018-11-16
    • 1970-01-01
    相关资源
    最近更新 更多