element ui官方的文档是不是有问题啊?Dialog 对话框

Dialog 对话框

里面的下划线不识别:methods: { handleClose(done) { this.$confirm('确认关闭?') .then(\_ => { done(); }) .catch(\_ => {}); } }
把下划线改成括号()就正常了
`methods: {

handleClose(done) {  
    this.$confirm('确认关闭?')  
        .then(() => {  
            done();  

})

        .catch(() => {});  

}
}`
https://element.eleme.cn/#/zh-CN/component/dialog#attributes

阅读 2.9k
2 个回答

_ 只是个变量名罢了,JS 的变量名是可以以 _$ 开头的。

倒是你粘贴的为啥前面多了个反斜杠?这个肯定不认呐。

没问题啊。_ 下划线表示参数啊。

this.$confirm('确认关闭?')

promise

有空多看看Promise的和箭头函数的文档啊。

this.$confirm('确认关闭?')
  .then(_ => {
    done();
  })
  .catch(_ => {});

你说的不识别下划线是啥意思?
相当于

.then((_) => {
    done();
  })

相当于

.then(function(_){
    done();
  })
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题