Home  >  Article  >  Web Front-end  >  How to obtain data in javascript in WeChat applet

How to obtain data in javascript in WeChat applet

不言
不言Original
2018-06-27 11:01:172423browse

This article mainly introduces the relevant information about WeChat applet obtaining data in javascript. Here is an example to illustrate how to obtain data in javascript. I hope it can help everyone. Friends in need can refer to it

WeChat applet gets data in javascript

How does wxml get data in js

Example:

wxml:

<text id="twl">{{txt}}</text>

Through the above {{txt}}, you can correspondingly obtain the value of txt defined under data in js

In js:

data: {

  txt:{}
  }

First define a "container" txt in the data: {}, an empty space in {} means that the value is passed in from other places, of course {} You can also directly write data in it, such as txt: {'123'}. The above wxml obtained is equivalent to 589037633b993ac7542fd0c811e25b10123273e21371c5d5e701d3c98517a0bfa41; pass the value to the container through other methods and use a This.setData({}) method, such as:

onLoad: function (options) {
 
   var ta=options.kind;

   this.setData({

    txt:ta,

   })

 },

In this way, the value of txt defined in the data above is the value of ta.

I encountered a problem, the mini program must use https; I went to Tencent Cloud to apply for a free one, and then worked for a long time, but it still failed to bind and the prompt "The specified login session does not exist..."

Later I found out that I had to double-click the certificate file to install the certificate... Embarrassing

The above is the entire content of this article. I hope it will be helpful to everyone's study. More Please pay attention to the PHP Chinese website for related content!

Related recommendations:

Introduction to the life cycle of the WeChat mini program page and audio playback and monitoring

WeChat mini program How to obtain the QR code

Introduction to user data decryption in WeChat mini program

The above is the detailed content of How to obtain data in javascript in WeChat applet. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn