一、知識點
1.在slot標籤中通過v-bind繫結插槽可以使用的屬性
'user'
:list=
'list'
>slot<
/slot>
在template標籤中,使用v-slot:default=『scope』
scope:template標籤中可以使用的作用域物件
default
='scope'
>}}
<
/template>
二、完整**
html**:
>
default
='scope'
>
}//lisi
}// [ 1, 2, 3, 4, 5 ]
<
/template>
你好<
/template>
slit2-----
<
/template>
<
/my-div>
<
/div>
js**:
newvue(
, methods:
, components:
, list:[1
,2,3
,4,5
]}},
template:
` slot
slot
slot
hello
world
`}}}
);}
Vue中的插槽 具名插槽 作用域插槽
1 vue中插槽的作用和使用方法 定義乙個名cmpone子元件,為該子元件新增內容應該在子元件的template中定義,直接在父元件的標籤中裡定義的內容不會被渲染,如下例 使用插槽後渲染的內容span cmp one div const cmpone const vm newvue script 結...
Vue 中的作用域插槽
vue.component child template let vm new vue 上面 如果此時有個需 child元件在很多地方會被呼叫,我希望在不同的地方呼叫child的元件時,這個列表到底怎麼迴圈,列表的樣式不是child元件控制的,而是外部child模版站位符告訴我們元件的每一項該如何渲...
Vue 中的作用域插槽
vue.component child template let vm new vue 上面 如果此時有個需 child元件在很多地方會被呼叫,我希望在不同的地方呼叫child的元件時,這個列表到底怎麼迴圈,列表的樣式不是child元件控制的,而是外部child模版站位符告訴我們元件的每一項該如何渲...