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,
SQL Server Database Glossary CSS Animation effect dedecms Website is hacked How to solve hijacking to other websites Count the number of letters (java Language implementation )Java Basics ( Three ) String In depth analysis The difference between static method and non static method And storage location Django Personal blog building tutorial --- Time classified archiving Keras Save and load model (JSON+HDF5)hive Summary of processing methods for a large number of small files Website mobile phone number capture method