UniApp input box prevents entering spaces

UniAppThe inputlabel while providing @inputevents, but only small program can use, so here we use the native onkeypressevent to avoid input spaces.

Insert picture description here

Solution:

<input class="uni-input"
  onkeypress="javascript:if(event.keyCode == 32)event.returnValue = false;"			
  v-model="password"
  type="text" name="password"
  :password="hidePsd"
  placeholder="请输入密码" />

[Note] corresponding to the spaces keyCode32.

Personal blog: Roc's Blog

Guess you like

Origin blog.csdn.net/peng2hui1314/article/details/108951827