Applet Components -> Component mass participation

Small program components, the components folder right click -> Create Folder -> Right Click -> New to create a component assembly

If you need to use more than one place, you can add the code in app.json, the equivalent of vue of global components.

"usingComponents" : {
     "BTN": "/ Components / folder name / js filename" 
  }

If the reference alone, json file directly referenced

"usingComponents" : {
     "BTN": "/ Components / folder name / js filename" , 
  }

If you want to use a page inside page as a component only needs to be changed and component format as he can (at page written inside, and suddenly feel the need as a component, you can use this method to direct the entire file thrown into components) must pay attention to transform the look

Note that the applet component has its own lifecycle, the document

Reference Gangster link   https://www.jianshu.com/p/7f366aba54c3

 

Feel and pass parameters between vue assembly has a similar Diudiu

Father to son

Parent components write-past values. After the transfer passed it, to direct his mother got this.data.name parent component such as a value-past    

Of course, this parent component name is the need to define the data in which the parent components

<view> <btn name='{{name}}'></btn> </view>

Subassembly 
the Component ({ 
  // VUE inside The props (abbreviation), here is the full name of the parent component for receiving a transmission over something. 
  Properties: { 
    name: { 
      type: String, // Type 
      value: 'XXX' // Default 
    } 
  }, 
  Data: { 
    
  } 
})

 

Father of the child we pass out first thing in the sub-assembly point

De thing subassembly engage 
the Component ({
// VUE inside The props (abbreviation), here is the full name of the parent component for receiving a transmission over something. Properties: { name: { type: String, // Type value: 'xxx ' // default } }, Data: { }, Methods: { giveFarther () { the this .triggerEvent (' giveFarther ', {xixi: "666 by value success" }); // this is the event name giveFarther followed with the value is passed in the past } } })
<View> 
  <BTN name = '{{name}}' the bind: giveFarther = "getSonName"> </ BTN> // this is bound to a component subassembly event name is then written in the js giveFarther 
</ view> 

imagine the following JS file is Kazakhstan

giveFarther (EV) {
  console.log (EV) // print to see
}

Gangster accompanying link: https://www.jianshu.com/p/ea830fe470fa

 

Guess you like

Origin www.cnblogs.com/TreeCTJ/p/11613624.html