最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

h函數(shù)的使用方法

2021-07-31 22:41 作者:忘魂兒  | 我要投稿


## h函數(shù)
### h() 函數(shù)是一個(gè)用于創(chuàng)建 vnode 的一個(gè)函數(shù)
#### 其實(shí)更準(zhǔn)確的命名是 createVNode() 函數(shù),但是為了簡便在Vue將之簡化為 h() 函數(shù)
### h函數(shù)的使用
#### 它接受三個(gè)參數(shù):("標(biāo)簽名|組件",插入標(biāo)簽內(nèi)的屬性|事件,向這個(gè)標(biāo)簽|組件內(nèi)插入的內(nèi)容)
##### 有時(shí)為了避免產(chǎn)生歧義,可以將null作為第二個(gè)參數(shù)傳入,將children作為第三個(gè)參數(shù)傳入
### h函數(shù)的基本使用
#### 簡單寫法
import {h} from 'vue'
export default {
 ?name: 'Home',
 ?render() {
 ? ?return ?h("span",{class:"sp"},"我是h出來的span")
 ?},
}
#### 多數(shù)據(jù)寫法
import {h} from 'vue'
export default {
 ?
 ?render() {
 ? ?return h("div",null,[
 ? ? ?h("h2",null,"about"),
 ? ? ?h("span",{class:"sp"},"我是h出來的span")
 ? ?])
 ?},
}
### 函數(shù)組件和插槽的使用

home組件

import about from './About.vue'
import {h} from 'vue'
export default {
 ?name: 'Home',
 ?render() {
 ? ?return ?h(about,null,
 ? ?{
 ? ? ?default1: props=>h("span",null,`"我是home傳給about的具名插槽"+${props.name}`) //這個(gè)default1就是插槽的名字
 ? ?}
 ?)
 ?},
}

about組件

import {h} from 'vue'
export default {
 ?
 ?render() {
 ? ?return h("div",null,[
 ? ? ?h("h2",null,"about"),
 ? ? ?this.$slots.default1?this.$slots.default1({name:'xwl'}):h("h2",null,"aboutDefault"),
 ? ?])
 ?},
}


h函數(shù)的使用方法的評論 (共 條)

分享到微博請遵守國家法律
徐闻县| 万载县| 赤峰市| 夏邑县| 阜城县| 南康市| 微山县| 叶城县| 深泽县| 张家口市| 锦屏县| 洱源县| 普安县| 博白县| 云浮市| 遂川县| 巴彦县| 教育| 镇坪县| 理塘县| 安义县| 乌兰浩特市| 澄城县| 沅陵县| 海宁市| 紫阳县| 平泉县| 马龙县| 南通市| 观塘区| 江北区| 徐汇区| 安塞县| 长丰县| 萨迦县| 张家港市| 绍兴市| 凤凰县| 江城| 公安县| 彭阳县|