Component definition
Component({ // behavior1.js // module.exports = Behavior({ // behaviors:
[require('behavior2.js')], // definitionFilter(defFields, definitionFilterArr)
{},// Defining segment filters , For custom component extensions . // }) // be similar to mixins and traits Code reuse mechanism between components based on behaviors: [require(
'behavior1.js')], // External properties of components , Is the mapping table from property name to property setting properties: { myProperty: { // Property name
type: String, // type ( Required ), Currently accepted types include :String, Number, Boolean, Object, Array,
null( Represents any type ) value: '', // Property initial value ( Optional ), If not specified, one is selected based on the type observer: function (newVal,
oldVal) {} // The function to execute when the property is changed ( Optional ), It can also be written in methods The method name string defined in the section , as :'_propertyChange' },
myProperty2: String // Simplified definition }, // Component data data: { A: [{ B: 'init data.A[0].B' }]
}, // Private data , Can be used for template rendering relations: {}, // Definition of relationship between components externalClass: [], // External style classes accepted by the component
// Some options options: { multipleSlots: true // Enable multiple options in component definition slot support }, lifetimes: { //
Life cycle function , Can be a function , Or one in the methods The method name defined in the section created: function () {},
// Executed when the component instance is just created , Note that it cannot be called at this time setData attached: function () {}, // Executed when the component instance enters the page node tree
ready: function () {}, // Execute after the component layout is complete moved: function () {},
// Executed when the component instance is moved to another location in the node tree detached: function () {}, // Executed when the component instance is removed from the page node tree error:
function () { // The page is displayed }, show: function () { // The page is displayed }, hide: function () {
// The page is hidden }, resize: function (size) { // Page size change } }, pageLifetimes: { //
The lifecycle function of the page where the component is located created: function () {}, // Executed when the component instance is just created , Note that it cannot be called at this time setData attached
: function () {}, // Executed when the component instance enters the page node tree ready: function () {}, // Execute after the component layout is complete moved:
function () {}, // Executed when the component instance is moved to another location in the node tree detached: function () {},
// Executed when the component instance is removed from the page node tree error: function () { // The page is displayed }, show: function () { //
The page is displayed }, hide: function () { // The page is hidden }, resize: function (size) { // Page size change } }
, // Component approach , include ( Event response function ) and ( Any custom method ) methods: { onMyButtonTap: function () { this.
setData({ // The way to update properties and data is similar to updating page data myProperty: 'Test' }) }, _myPrivateMethod:
function () { // Internal methods recommend starting with an underline this.replaceDataOnPath(['A', 0, 'B'],
'myPrivateData') // Here will be data.A[0].B Set to 'myPrivateData' this.applyDataUpdates()
// Update data }, _propertyChange: function (newVal, oldVal) {} } }) <!-- assembly custom-
component.wxml --> <custom-component> <view>{{myProperty}}</view> <button
bindtap='onMyButtonTap'>Button</button> <view>{{A[0].B}}</view> <button bindtap=
'_myPrivateMethod'>_myPrivateMethod</button> </custom-component> { "component":
true, "usingComponents": {} }
Page usage components
{ "usingComponents": { "my-component": "/components/custom-component" } } <!--
Page's WXML --> <my-component my-property="example" />

Technology
©2019-2020 Toolsou All rights reserved,
( Super detail )Eclipse Using tutorials —— use Eclipse Create first HelloWorld! Database operation 5 code implementation mysql Addition, deletion, modification and query of database What can MCU do , Do you have any interesting works made by MCU or open source hardware Go to the interview after reading this , Steady over ~~ Single linked list of primary data structure (C Language implementation )SQL Comprehensive questions Employee unit comprehensive questions Python Implementation of Hanoi Tower code VHDL——JK trigger It's over , Starting salary 30k