Specific use method of Ref in Vue2

This article describes the specific use of REF in Vue2, and shares it to everyone, as follows.

1, we first define two components


  
JS portion

VUE .Component (‘Navbar’, {Template: ‘
{NAVS}}

‘, DATA: Function () {Return {NAVS: 1}}}); Vue.component (‘Pagefooter’, {Template : ‘
{{Footer}} ‘, data: function () {return {footer: 11}}};
  
How to directly access it directly Navbar's NAVS and PAGEFOOTER's FOOTER value? This is used to use

Modify the component

New Vue ({EL: ‘# app’, create: function () {}, mounted: function () {tHis. $ REFS.NAVBAR.NAVS = 222 // Ready, // How to directly access Navbar’s NAVS and PAGEFOTER’s FOOTER value, console.log (this. $ refs.navbar.navs); console.log (this. $ REFS.PAGEFOOTER.FOOTER;}})
If only one ordinary label is used
  
His role and:
Document.QuerySelector (‘[ref = demo] ‘);

 The above is all the contents of this article, I hope to help everyone, I hope everyone supports Tumi Cloud .  
© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment