项目是 typeScript 写的,使用 element-ui 官网的 例子 ,可以正常使用,但是 编译器报错
“Parameter ‘value’ implicitly has an ‘any’ type.”
***官网代码人如下:***```
(this as any).$prompt('请输入取消理由', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputPattern: /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/,
inputErrorMessage: '邮箱格式不正确'
}).then((
value
) => {
this.$message({
type: 'success',
message: '你的邮箱是: ' + value
});
}).catch(() => {
this.$message({
type: 'info',
message: '取消输入'
});
});
***修改后的代码***:
(this as any).$prompt('请输入取消理由', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputPattern: /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/,
inputErrorMessage: '邮箱格式不正确'
}).then((
yourEmail : any = { value: "" }
) => {
this.$message({
type: 'success',
message: '你的邮箱是: ' + yourEmail.value
});
}).catch(() => {
this.$message({
type: 'info',
message: '取消输入'
});
});