ElemeFE / element-react

Element UI
https://elemefe.github.io/element-react/index
MIT License
2.83k stars 444 forks source link

typescript Property 'value' does not exist on type 'MessageBoxData'.ts(2339) #1034

Open maozhenzhong opened 4 years ago

maozhenzhong commented 4 years ago

Description

export const myPrompt = (message: string = '请输入内容?', title: string = '提示', errorMessage: string = '请输入内容', callback: Function) => { MessageBox.prompt(message, title, { confirmButtonText: '确定', cancelButtonText: '取消', inputPattern: /\S/, inputErrorMessage: errorMessage }).then(({ value }) => { // ts error Property 'value' does not exist on type 'MessageBoxData'.ts(2339) Message({ type: 'success', message: '你的邮箱是: ' + value }); }).catch(() => { Message({ type: 'info', message: '您已取消该操作' }); }) }

Reproduce Steps

Error Trace (if possible)

Property 'value' does not exist on type 'MessageBoxData'.ts(2339)

lee-Tony commented 4 years ago

我也有这个问题,请问你解决了吗?

maozhenzhong commented 4 years ago

我也有这个问题,请问你解决了吗?

没有

qinhir commented 2 years ago

进行类型强转

this.$prompt('新增属性信息', '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      inputPlaceholder: '请输入属性信息'
    }).then(res => {
      const value = (res as MessageBoxInputData).value
})