【问题标题】:How to make this buttton to generate and specific text?如何让这个按钮生成特定的文本?
【发布时间】:2022-11-22 22:02:50
【问题描述】:

我有一个像这样在 vue 中创建的按钮

 <div v-else>
          <div class="flex items-center justify-center">
            <Default type="submit" :enabled="!formIsValid || loading">
              <div class="inline-flex items-center justify-center">
              <span v-if="loading">Dibujando</span>
              <div v-else class="inline-flex">
                <div >Random</div>

当我点击随机按钮时,我需要做什么才能在文本区域放置文本?该按钮有效,但不输出任何内容。我不知道我必须将文本放在哪里才能与此按钮进行交互。我是 vue 的菜鸟,对不起。

我期待在文本区域输出文本。

【问题讨论】:

  • 欢迎,你能提供一个Minimal, Reproducible Example
  • 哪个按钮?哪个文本?具体在哪里?你试过什么?什么不起作用?

标签: vue.js vue-component


【解决方案1】:

您可以在 textarea 上使用 v-model 并覆盖单击按钮时的值。

https://vuejs.org/guide/essentials/forms.html

  Example:
  https://codepen.io/cowall/pen/ZERroqZ

  <textarea v-model="message"></textarea>
  <button @click="clickFunction">click me</button>

   clickFunction() {
      this.message = "Hello You"
    }

【讨论】:

  • 此处不允许仅链接答案。请在此处共享代码的相关部分。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-03-14
  • 1970-01-01
  • 2011-04-16
  • 2021-06-01
  • 2014-09-05
  • 2019-01-05
  • 1970-01-01
相关资源
最近更新 更多