日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 前端技术 > vue >内容正文

vue

vue3 + typescript + antd-design-vue(3.x)Modal.form()

發(fā)布時間:2023/12/31 vue 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 vue3 + typescript + antd-design-vue(3.x)Modal.form() 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

首先介紹一下ant-design-vue Modal

這里是官網(wǎng) ant-design-vue
Moadl支持Modal.confirm

Modal.confirm({title: 'Do you Want to delete these items?',icon: createVNode(ExclamationCircleOutlined),content: createVNode('div', { style: 'color:red;' }, 'Some descriptions'),onOk() {console.log('OK');},onCancel() {console.log('Cancel');},class: 'test',});

這里可以看到content使用了createVNode函數(shù),這里我們可以引入一個tsx組件作為node接入進(jìn)來

注意:vue3中的tsx寫法這里只介紹兩種
一種是render函數(shù)形式,一種是setup

export default defineComponent({props: {msg: {type: String,default: ''}},render () {const testClick = () => {this.$emit('submit')}const confirm = () => {return (<button onClick={testClick}>hello</button>)}return confirm()}

render函數(shù)形式的組件可以通過this獲取vue實例,進(jìn)而進(jìn)行操作(這里用到父子組件傳值)

export default defineComponent({props: {msg: {type: String,default: ''}},setup(props, { emit }) {const testClick = () => {emit('test')}const comfirm = {render() {<button onClick={testClick}>hello</button>},};return {comfirm}} })

這里是setup形式的tsx,這里官網(wǎng)也有介紹
vue3 jsx/tsx

接下來是在Modal.confirm()中的content使用該組件

import TestConfirm from './test';const confirm = () => {Modal.confirm({title: 'Confirm',icon: createVNode(ExclamationCircleOutlined),content: createVNode(TestConfirm, {onSubmit() {}}),// content: () => h(TestConfirm, { msg: 'hello word' }),okText: '確認(rèn)',cancelText: '取消',});};

’TestConfirm‘是tsx子組件,子組件的emit出來的方法在content中要以on開頭寫成駝峰。

以上就是vue3使用tsx在Modal.form({content})中結(jié)合的使用

總結(jié)

以上是生活随笔為你收集整理的vue3 + typescript + antd-design-vue(3.x)Modal.form()的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。