search
HomeWeChat AppletMini Program DevelopmentDeveloping WeChat mini programs from scratch (2)

Developing WeChat mini programs from scratch (2)

Mar 21, 2018 am 09:42 AM
Appletsdevelopprogram

In the previous chapter, we shared with you how to develop a WeChat applet from scratch (1). After registering the applet and adding a new project, the general preparation and development has been completed. What we want to share in this chapter is to create a simple page. , specific steps to create a mini program page:

1. Add a directory in pages

Select page, right-click the mouse, open from the hard disk, open the hard disk file, and create a new file Fold test (or click the + sign to add directories one by one and add the required files under the directories)







Or add it like this

2. Create a new wxml file

Create a new empty wxml file under the test folder



3. Edit the test.wxml file

For the convenience of testing, let’s just fill in some content

<view class="container">  
    <text>这是我的test页面哦哦!!!</text>  </view>

4. The same method, Create the test.js file and edit the test.js file

Create a new empty js file under the test folder

Use the same method as above to create a test.js file in the test directory. In order to facilitate our testing Just fill in some content (you can also leave it blank, or just leave the file blank)

//test.js  //获取应用实例  var app = getApp()  
Page({  
  data: {  
    userInfo: {}  
  },  
  onLoad: function () {  
    console.log(&#39;onLoad test&#39;);  
  }  
})

5. Add the test page to app.json

Open the global file app.json and add it in the file "pages/test/test" (add a directory where the test page is located)


6. Add a jump access link on the homepage

Everything is ready, everything that needs to be added has been added. Here is the moment to witness the miracle. Write a page entry on the homepage, jump to the page we want to test, directly on the homepage pages/index/index.wxml Add a piece of code and a link

<view class="btn-area">  
   <navigator url="/pages/test/test" hover-class="navigator-hover">跳转test页面</navigator>  
 </view>


#7. Test

Save the code, click the compile button above, all codes After running it, click "Jump to test page" on the homepage, and the jump is successful, as shown below.


8: Set the page title

Setting the page title is a very simple step. Find the page you are on. directory, create a new json file (usually automatically generated, if not, create a new one), such as the test page we built last time, find the pages/test/ directory, create a new test.json file and add the following code.

{  "navigationBarTitleText": "详情页"}


The effect is as follows:

OK, here, create the page and completing the jump between pages

Related recommendations:

Developing WeChat mini programs from scratch (1)

A brief introduction to WeChat mini programs

WeChat applet global configuration development example

The above is the detailed content of Developing WeChat mini programs from scratch (2). 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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools