just a month after learning Mini Program, I want to do a test of Mini Program,
1, let the user enter the name;
2, and then convert the name to a numerical value;
3, set several arrays and find the corresponding array according to the converted values;
4, output the results of the corresponding array to the user.
I got stuck in the second step. I received the name entered by the user with input, and the result was Null.
onLoad: function (options) {
this.data.name = wx.getStorageSync("name");
this.setData({ name: this.data.name });
this.setData({ words: parseFloat( this.data.name) });
},
asked a friend at the front end, he said that it must be Null, because there is no number in the input name, and the method will not transfer the value.
question:
1. Is there any other way to convert names into simple numbers? 1, 2, 3, 4, etc., it is convenient for me to find the corresponding content from the array;
2, is my idea of this implementation correct?