vue 特殊屬性

2021-09-27 13:38:53 字數 2013 閱讀 4749

長用於構建動態元件且基於 dom 內模板的限制

插槽,推薦使用2.6.0新出的v-slot

用於標記往哪個具名插槽中插入子元件內容。

被 2.5.0 新增的 slot-scope 取代。推薦 2.6.0 新增的 v-slot

用於表示乙個作為帶作用域的插槽的 元素,它在 2.5.0+ 中被 slot-scope 替代

用於將元素或元件表示為作用域插槽

ref 被用來給元素或子元件註冊引用資訊。引用資訊將會註冊在父元件的 $refs 物件上。如果在普通的 dom 元素上使用,引用指向的就是 dom 元素;如果用在子元件上,引用就指向元件例項

key 的特殊屬性主要用在 vue 的虛擬 dom 演算法,在新舊 nodes 對比時辨識 vnodes

推薦使用2.6.0新出的v-slot

用於將元素或元件表示為作用域插槽

="hello"

>

<

!-- v-

for迴圈中通常使用key屬性,標明每個元素的唯一性,利於虛擬dom演算法 --

>

for=

"item of data"

:key=

"item"

>

}<

/div>

<

/div>

<

!-- 構建動態元件 --

>

"currentcomp"

>

<

/div>

"changecomponent"

>改變元件<

/button>

<

!-- 插槽 --

>

<

!-- 將插槽名為inex的內容傳遞到子元件名為index的插槽中 --

>

"index"

>在index中的slot中顯示<

/div>

<

/index>

<

/div>

<

/template>

import vue from

'vue'

import login from

'../components/login.vue'

import index from

'../components/index.vue'

export

default

,data()

},methods:

else}}

}<

/script>

<

!-- add "scoped" attribute to limit css to this component only --

>

<

/style>

="hello"

>

"'red'"

>

我是index 元件

<

/div>

<

!-- 定義名為index的插槽 --

>

"index"

>

<

/slot>

<

/div>

<

/template>

export

default}}

<

/script>

<

!-- add "scoped" attribute to limit css to this component only --

>

.hello div

<

/style>

93 特殊屬性

python 特殊屬性 文件 python物件中包含了很多雙下劃線開始和結束的屬性,這些是特殊屬性,有特殊用法。這 裡我們列出常見的特殊屬性 ipython 執行效果 in 12 c c 3 in 13 cout 13 main c at in 14 dir c out 14 class delat...

Linux檔案特殊屬性

文中有不對或者有不清楚的地方,請大家告訴我,謝謝!linux檔案特殊屬性 linux檔案特殊屬性主要包括它的預設許可權 隱藏屬性和特殊許可權 suid sgid sbit 下面我們就來分別講解它的這些特殊屬性。1.linux檔案預設許可權 umask 我們在新建立乙個檔案時,它都有自己的預設屬性。它...

特殊屬性之 ref

ref被用來給元素或子元件註冊引用資訊 引用資訊將註冊在父元件的 refs物件上 如果在dom元素上使用,引用指向的就是dom元素 如果在子元件上使用,引用指向的就是元件例項 ref p hellop ref child child component 當v for用於元素或元件時,引用資訊將是包含...