【问题标题】:Button and text label in vue are not clickablevue中的按钮和文本标签不可点击
【发布时间】:2020-03-28 20:07:12
【问题描述】:

所以我在 vue 中创建了一个注册页面,当我想在框中输入内容或单击注册/登录按钮时,它不会做任何事情,但是如果我点击 TAB 并输入我的密码,然后点击 TAB 并按 ENTER 它会工作的。

这是代码:

<div class="login-box">
  <div v-if="pageMethod == 'login'">
    <h1 class="display-4">Authentication</h1>
    <p class="lead small">You are registered on this server. Insert your account's password to proceed with the authentication.</p>
  </div>
  <div v-if="pageMethod == 'register'">
    <h1 class="display-4">Registration</h1>
    <p class="lead small">You are not registered on this server. Insert your account's password to proceed with the reegistration.</p>
  </div>
  <div class="input-group">
    <input v-model="password" :type="showPassword == true ? 'text' : 'password'" class="form-control"
      placeholder="Password">
    <div @click="showPassword = !showPassword" class="input-group-prepend">
      <span class="input-group-text">
        <i :class="showPassword != true ? 'fas fa-eye-slash' : 'fas fa-eye'"></i>
      </span>
    </div>
  </div>
  <button v-if="pageMethod == 'login'" @click="sendAuth(true)" class="btn btn-primary mt-3">Login</button>
  <button v-if="pageMethod == 'register'" @click="sendAuth(false)" class="btn btn-primary mt-3">Register</button>
</div>

这是登录框 css 部分:

.login-box {
text-align: center;
z-index: 1;
height: 100%;
width: 400px;
position: absolute;
right: 0px;
top: 0px;
display: flex;
background-color: rgba($card-bg, 0.8);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 10px 15px;
h1 {
  font-family: 'HouseScript';
  font-size: 50px;
  line-height: 50px;
  color: #fff;
}

【问题讨论】:

    标签: css json vue.js


    【解决方案1】:

    我修好了。有一个徽标悬停在文本标签和按钮上。我不得不添加指针事件:无;在标志的 css 部分。感谢您的建议。

    【讨论】:

      【解决方案2】:

      你必须使用 tabIndex 并且还要听 Enter @keyup.enter

      <input v-model="password" :type="showPassword == true ? 'text' : 'password'" class="form-control" placeholder="Password" tabindex="0">
      ...
      <button v-if="pageMethod == 'login'" @click="sendAuth(true)" class="btn btn-primary mt-3" tabindex="1" @keyup.enter="sendAuth(true)">Login</button>
      <button v-if="pageMethod == 'register'" @click="sendAuth(false)" class="btn btn-primary mt-3" tabindex="2" @keyup.enter="sendAuth(false)">Register</button>
      

      【讨论】:

      • 我已经替换了你告诉我的内容,但现在文本框的一小部分是可点击的,按钮仍然不可点击。
      • codepen.io/brospresident/pen/vYOvqaZ 我无法让它看起来应该在那个网站上。这是我第一次使用它。
      • 不行,只是粘贴代码是不够的,还需要插上Vue等东西。可能你有一些 CSS 问题,这就是为什么只有一小部分是可点击的
      • pastebin.com/gvMq5YdU 这是我的 CSS 部分。我已经将带有登录框的部分放在第一篇文章中,但也许你可以看到其他包含整个文件的内容
      • 我修好了。有一个徽标悬停在文本标签和按钮上。我不得不添加指针事件:无;在标志的 css 部分。感谢您的建议。
      猜你喜欢
      • 2016-10-09
      • 2011-04-27
      • 2021-03-12
      • 1970-01-01
      • 1970-01-01
      • 2015-09-26
      • 2018-05-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多