Basic introduction applets - small micro-channel learning program summary (a)

Introduction 1. applet

// 1.小程序不是运行在浏览器中,因此没有BOM和DOM对象
// 例如:
// console.log(window)  => undefined
// console.log(document) =>undefined

// 2.小程序的JS有一些额外的成员
// App 方法 用于定义应用程序实例对象
// Page 方法 用于定义页面对象

// getApp 方法 用来获取全局应用程序对象
// getCurrentPages 方法 用来获取当前页面的调用栈(是一个数组)
// wx 对象 用来提供核心API的

// 3.小程序的JS是支持CommonJS规范的
// const foo = require("./utils/foo.js")
// foo.say("world")

1. applet support commonJS usage

2. Small referenced in the program include the import and use

2.1import quote

You can use the target file import defined in the document template, the definition of the file path to the page do not appear in the file app.json

Defined template item called a file in item.wxml

In index.wxml import the template file:

The results are as follows:

The results of the introduction of non-template in the code block does not introduce item.wxml, and will only be introduced in the name of the item code block

2.2include quote

may include in addition to the target file <template /> the introduction of the entire code

The results are as follows:

Published 13 original articles · won praise 19 · views 10000 +

Guess you like

Origin blog.csdn.net/xibei19921101/article/details/104058586