Vue2.0 Parentian Component Tutorial Tutorial Detailed

Vue.js is what

Vue.js (pronunciation / vjuː /, similar to view) is a progressive framework for building a user interface. Unlike other heavyweight frames, Vue uses the design of the upward incremental development. Vue’s core library only pays attention to the view layer, it is not only easy to get started, but also facilitates the third party library or existing project integration. On the other hand, when used in combination with the library supported by the single file component and the VUE ecosystem, Vue is fully capable of driving the complex single-page application.

Learning notes: When the parent component calls submas, when the parent component calls sub-components, you want to pass the function body in the parent component.

1. Via PROPS: need Applicable from subcomponent pass parameters to parent components // parent components .VUE

   Import Okinput from '../ok-input/okinput.vue'; Export Default {Props: {}, Data () {Return {Number: { }, Callbacknum: Function (x) {console.log (x);}};}, methods: {}, components: {'ok-input': Okinput}}; 
// Subcaps.comVue

IMport {INPUT, SELECT, OPTION, Button} from ‘Element-UI’; import ‘Element-Ui / lib / theme-default / index.css’; export default {props: {params: {type: Object, default: { TYPE: ”}}, callback: {}}, data () {return {x: ‘hah’, number: {handlefun (val) {this.callback (val); // Transfer the parameters back to the callback function}}} in the parent component, Components: {‘EL-INPUT’: INPUT,}};
  2. Through $ EMIT: Just achieve  
// parent component .Vue

Import Okinput from ‘../ok-input/okinput.vue’; export default {}: {}, data () {return {number: {}};}, methods: {handleage EVT) {console.log (; // Receive the current object from the sub-components}}}, Components: {‘OK-INPUT’: OKINPUT}};

// Subcapsat .Vue
Import {INPUT, SELECT, OPTION, Button} from 'Element-UI'; Import 'Element-Ui / Lib / Theme-Default / Index.css'; Export Default {Props: {Params: {Type: Object, Default: {Type: ''}}, callback: {}}, data () {}} Return {x: 'Hah', Numval: ''};}, methods: {handlechange (evt) {this. $ EMIT ('Change', EVT); // Pass the current object EVT to the parent component},},
is small as described above. The tutorial of the Vue2.0 parent sub-component transfer function is presented, I hope to help everyone. If you have any questions, please leave a message, the small package will reply to everyone. Thank you very much for your support of Tumi Cloud Website!

© Copyright Notice
Just support it if you like
comment Grab the couch

Please log in to comment