美文网首页
input框 中文模式 拼音问题

input框 中文模式 拼音问题

作者: 成神之路_be73 | 来源:发表于2021-07-28 14:28 被阅读0次

    问题:
    input需要监听变化,在使用中文模式进行输入时,页面上的拼音会引起变化,触发事件发送接口
    解决方法:
    将@change变为@input

    <template>
      <input
        v-model="keyword"
        :placeholder="placeholder"
        @input="handleKeyup"
      />
    </template>
    <script>
    export default {
      data() {
        return {
          placeholder: 'placeholder',
          keyword: '',
          time: null,
        };
      },
      methods: {
        handleKeyup: function () {
          clearTimeout(this.time);
          let keyword = this.keyword;
          keyword = keyword && String(keyword).trim();
          if (keyword) {
            this.time = setTimeout(() => {
              xxxxxxxx;
            }, 300);
          }
        },
      },
    };
    </script>
    

    相关文章

      网友评论

          本文标题:input框 中文模式 拼音问题

          本文链接:https://www.haomeiwen.com/subject/hxyzmltx.html