Home > Web Front-end > JS Tutorial > body text

How to obtain data in javascript in WeChat applet

不言
Release: 2018-06-27 11:01:17
Original
2382 people have browsed it

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>
Copy after login

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

In js:

data: {

  txt:{}
  }
Copy after login

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 123; 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,

   })

 },
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
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!