vue 插槽的定義

2021-10-20 06:11:54 字數 796 閱讀 6674

<

!doctype html>

"en"

>

"utf-8"

>

"viewport" content=

"width=device-width, initial-scale=1.0"

>

lesson 20

<

/title>

"">

<

/script>

<

/head>

"root"

>

<

/div>

<

/body>

//slot 插槽

//父模版裡呼叫的資料屬性,使用的都是父模版裡的資料

//子模版裡呼叫的資料屬性,使用的都是父模版裡的資料

//slot預設值設定

//具名插槽的定義(}

, template:

` }

}header

footer

`});

component

('layout',)

;component

('myform',}

,//普通插槽,繫結事件

template:

` defalt value

`});

mount

('#root');

<

/script>

<

/html>

vue插槽樣式 vue中的插槽slot

插槽 slot 是元件的一塊html模板,父元件決定這塊模板顯不顯示以及怎麼顯示。位置由子元件自身決定 slot現在元件template的什麼位置,父元件傳過來的模板將來就顯示在什麼位置 匿名插槽 只能有乙個,可以放在元件的任何位置 在父元件在裡面寫了html模組 子元件的匿名插槽被下面的div模板...

vue插槽樣式 vue基礎之插槽

categories vue基礎 tags 插槽element ui 插槽slot 插槽 vue內建元件 做為承載分發內容的出口 普通插槽 插槽使用 全域性元件 第乙個引數是元件名,第二個引數是options vue.component vbtn template 我是頭部元件 var vconte...

具名插槽和匿名插槽 vue 插槽

插槽就是子元件中的提供給父元件使用的乙個佔位符,用 表示,父元件可以在這個佔位符中填充任何模板 如 html 元件等,填充的內容會替換子元件的標籤。1.插槽 建立slots.vue 主檔案引入 原生效果 插槽效果。這樣在中間可以巢狀內容 這裡的內容會被插入到slots中顯示 我是插槽 2.預設插槽 ...