且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

维.这段代码去哪里了?

更新时间:2023-11-29 22:10:58

看起来问题在于你从声明式思考转向命令式思考.当你想确认某事时,你应该设置一个 confirmPrompt 数据项,并且组件应该以与观察警报字符串大致相同的方式观察它.

It looks like the problem is that you got away from thinking declaratively and went to thinking imperatively. When you want to confirm something, you should set a confirmPrompt data item, and the component should be watching it in much the same way it watches the alert string.

确认响应应该有一个数据项来指示您是在等待响应,还是已确认或已取消.都是程序状态.

There should be a data item for the confirmation response to indicate whether you're waiting for a response, or it was confirmed or it was canceled. It's all program state.

使用 $refs 是一种代码异味.这并不总是错的,但您应该始终考虑为什么要这样做.诸如 me.$refs.loader.hide(); 之类的东西建议程序状态更改应该通过设置 loaderIsVisible 数据项来控制,例如.

Using $refs is a code smell. It's not always wrong, but you should always think about why you're doing it. Things like me.$refs.loader.hide(); suggest program state changes that should be controlled by setting a loaderIsVisible data item, for example.