vue:v-if条件

发布于 2025-02-11 01:47:00 字数 416 浏览 1 评论 0原文

在我的VUE应用程序中,我有以下代码:

<div v-if="partner == true && kids == false" class="row">
   <input type="text" id="testInput">
</div>

现在,当我想尝试此代码段时,它不会呈现输入。我很确定它应该是因为变量目前具有正确的值。

我也尝试过,但这也不起作用:

<div v-if="partner && !kids" class="row">
   <input type="text" id="testInput">
<div>

条件是错误的还是该代码的问题是什么?

in my vue application I have following code:

<div v-if="partner == true && kids == false" class="row">
   <input type="text" id="testInput">
</div>

Now when I want to try out this code snippet it does not render the input. I am pretty sure it should because the variables have the right value at this moment.

I also tried this but this does not work either:

<div v-if="partner && !kids" class="row">
   <input type="text" id="testInput">
<div>

Is the condition wrong or what is the problem with this code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

听,心雨的声音 2025-02-18 01:47:00

您的代码很好:

new Vue({
  el: "#demo",
  data() {
    return {
      partner: true,
      kids: false
    }
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="demo">
  <div v-if="partner && !kids" class="row">
   <input type="text" id="testInput">
  </div>
</div>

Your code is fine:

new Vue({
  el: "#demo",
  data() {
    return {
      partner: true,
      kids: false
    }
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="demo">
  <div v-if="partner && !kids" class="row">
   <input type="text" id="testInput">
  </div>
</div>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文