国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

Vue組件模板及組件互相引用代碼實例

瀏覽:108日期:2023-02-01 08:03:27

1. vue組件都是由這三部分組成

<template> <div> </div></template><script> export default{}</script><style></style>

2. 組件間的引用

分3步走,假設(shè)現(xiàn)在有兩個組件 App.vue,和 Add.vue,現(xiàn)在要把Add.vue組件引入到App.vue組件中

App.vue

<template> // 第3步 <Add/></template><script> // 第1步 import Add from ’./components/Add.vue’ // 第2步 components: { Add } }</script><style></style>

3. 組件間數(shù)據(jù)的傳遞

假將要將App.vue組件中的數(shù)據(jù)傳遞到Ad.vue組件中

App.vue

<template> // 第3步 // 傳遞數(shù)據(jù),注意冒號 <Add :comments='comments'/></template><script> // 第1步 import Add from ’./components/Add.vue’ // 第2步 components: { Add }, // App組件中初始化的數(shù)據(jù) data(){ return { comments: [{ name: ’Bob’, content: ’Vue 還不錯’ }, { name: ’Cat’, content: ’Vue so Easy’ }, { name: ’BZ’, content: ’Vue so so’ } ] } } }</script><style></style>

Add.vue

<script> export default{ // 聲明接收comments數(shù)據(jù) props: [’comments’] }</script>

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Vue
相關(guān)文章:
主站蜘蛛池模板: 司法| 湘乡市| 仪陇县| 威宁| 民权县| 陇南市| 当雄县| 进贤县| 青神县| 库尔勒市| 灌南县| 马龙县| 云龙县| 滨州市| 卢氏县| 琼海市| 曲靖市| 小金县| 黄浦区| 西平县| 莱阳市| 鄂伦春自治旗| 平凉市| 松潘县| 荆门市| 邓州市| 黄大仙区| 庄浪县| 苏尼特右旗| 集贤县| 许昌县| 崇礼县| 灵武市| 玉山县| 金堂县| 新乡市| 梁山县| 安徽省| 泗阳县| 喀喇沁旗| 奉节县|