javascript - Problems with input positioning in the js front-end of the WeChat applet
天蓬老师
天蓬老师 2017-05-19 10:11:40
0
3
587

1. I wrote a WeChat applet, a Sudoku game, to determine whether it meets the requirements (Sudoku rules) based on the number entered. However, I encountered a problem, how to find the position of the number entered by the user, because it needs to be based on the number entered by the user. The position is passed into the corresponding script file to determine whether the rules are met, but because I am not very proficient in js, I cannot solve the positioning problem.

  1. <view class="page-body">

    <view class="bc" wx:for="{{numbers}}" wx:for-item="row" >
        <view wx:for="{{row}}" class="bc_ bc_{{item}}" bindtap="oninput"> 
          <input wx:if="{{item == 0}}" auto-focus wxkey="*this" maxlength="1" value="" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" type="number" style="color:#000000" bindinput="EventHandle"/>
          <view wx:else>{{item}}</view>
        </view>
    </view>

    </view>

Where numbers is an array in the script file, and the style is implemented using two loops.
It will determine whether each number is zero (the array we wrote manually at the beginning, 0 represents user input). If it is zero, no characters (strings) will be displayed here.


Here is the front-end display code and display effect. The blank space is used for users to fill in numbers, but I don’t know how to find where the user entered the numbers. I hope someone can guide me. one time.

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(3)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!