国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

Vue 父子組件、組件間通信

2024-05-06 15:10:05
字體:
供稿:網(wǎng)友

本人對(duì)Vue組件間通信不懂,搜索了很多關(guān)于Vue 父子組件間通信介紹,下面我來記錄一下,有需要了解Vue 父子組件、組件間通信的朋友可參考。希望此文章對(duì)各位有所幫助。

<!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <title>組件</title>  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">  <meta name="apple-mobile-web-app-capable" content="yes">  <meta name="apple-mobile-web-app-status-bar-style" content="black">  <script src="../js/Vue.js"></script>  <script>    window.onload = function(){      var vm = new Vue({        el:'#box',        data:{},        components:{          aaa:{            template:'<h2>這是aaa組件<bbb></bbb></h2>',            components:{              bbb:{                template:'<h2>這是bbb組件</h2>'              }            }          }        }      });    }  </script></head><body><div id="box">  <aaa></aaa></div></body></html>
<!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <title>Document</title>  <script src="../js/vue1.0.js"></script>  <script>    //子組件獲取父組件的值    window.onload = function () {      var vm = new Vue({        el: '#box',        data: {          a: 'aaa'        },        components: {          'aaa': {            data(){              return {                msg: 111,                msg2: '這是父組件的數(shù)據(jù)'              }            },            template: '#aaa',            components: {              'bbb': {                //html中的my-msg這種形式,js中應(yīng)該采用駝峰命名myMsg                props: ['mmm', 'myMsg'],                template: '<h3>我是bbb組件->{{mmm}}<br>{{myMsg}}</h3>'              }            }          }        }      });    }  </script></head><body><div id="box">  <aaa>  </aaa></div><template id="aaa">  <h1>11111</h1>  <bbb :mmm="msg2" :my-msg="msg"></bbb></template></body></html>
<!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <title>Document</title>  <script src="../js/vue1.0.js"></script>  <script>    //子組件獲取父組件的值    window.onload = function () {      var vm = new Vue({        el: '#box',        data: {          a: 'aaa'        },        components: {          'aaa': {            data(){              return {                msg: 111,                msg2: '這是父組件的數(shù)據(jù)'              }            },            template: '#aaa',            components: {              'bbb': {                //html中的my-msg這種形式,js中應(yīng)該采用駝峰命名myMsg                props: ['mmm', 'myMsg'],                template: '<h3>我是bbb組件->{{mmm}}<br>{{myMsg}}</h3>'              }            }          }        }      });    }  </script></head><body><div id="box">  <aaa>  </aaa></div><template id="aaa">  <h1>11111</h1>  <bbb :mmm="msg2" :my-msg="msg"></bbb></template></body></html>            
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 元氏县| 兴业县| 寻乌县| 小金县| 水城县| 青岛市| 康保县| 沂水县| 万安县| 澄迈县| 山东省| 绿春县| 白沙| 敖汉旗| 河东区| 钦州市| 通河县| 紫金县| 泰宁县| 周口市| 自贡市| 南宁市| 海丰县| 赤水市| 左贡县| 琼结县| 鄂伦春自治旗| 栾城县| 东宁县| 临邑县| 蒲江县| 内丘县| 松溪县| 房产| 灌云县| 钦州市| 锡林郭勒盟| 赤峰市| 孟津县| 清丰县| 江城|