在 nativescript 的模态内打开模态
Open modal within modal in nativescript
当我在另一个模式中尝试打开一个模式时。我收到一条错误消息:
ViewHierarchy: parent is already presenting view controller close the current modal page before showing another one!
这是一个 playground sample,我怎样才能在一个模态中包含另一个模态?
复制
- 单击按钮(应弹出一个模式)
- 点击按钮(什么都不会发生,你会得到一个错误)
预期行为
您应该会看到一个新的弹出窗口打开。
我的环境
$ tns info
✔ Getting NativeScript components versions information...
✔ Component nativescript has 6.5.0 version and is up to date.
✔ Component tns-core-modules has 6.5.0 version and is up to date.
✔ Component tns-android has 6.5.0 version and is up to date.
✔ Component tns-ios has 6.5.0 version and is up to date.
这似乎是 NativeScript-Vue 当前版本(截至今天,v2.5.0)的问题。每次您尝试创建模态时,它都会尝试使用相同的父控制器,使用第一个模态作为第二个模态的父级将解决问题。但是没有解决方法,要么您必须完全自己处理模态,要么对 nativescript-vue 包的源代码进行修补。否则,您可以使用解决此特定问题的 v2.3.0(但我不确定您在 v2.5.0 上还有哪些其他好处,您可能需要查看更改日志)。
我建议你在 Github repo 上用你的 Playground 示例提出问题并 link 到这个 SO post,希望他们在下一个版本中修复它。
nativescript-vue 文档不清楚如何使用嵌套模式,因为它在@yukashima-huksay 的 post 之后被修复。但是github上有an example演示了它的用法。
可以使用 target
选项打开辅助模式,它可以针对当前视图(使用 this
)或元素(即 this.$refs[<some element>]
)。
// this
this.$showModal(SecondaryModal, { target: this });
// $refs
this.$showModal(SecondaryModal, { target: this.$refs['myView'] });
当我在另一个模式中尝试打开一个模式时。我收到一条错误消息:
ViewHierarchy: parent is already presenting view controller close the current modal page before showing another one!
这是一个 playground sample,我怎样才能在一个模态中包含另一个模态?
复制
- 单击按钮(应弹出一个模式)
- 点击按钮(什么都不会发生,你会得到一个错误)
预期行为
您应该会看到一个新的弹出窗口打开。
我的环境
$ tns info
✔ Getting NativeScript components versions information...
✔ Component nativescript has 6.5.0 version and is up to date.
✔ Component tns-core-modules has 6.5.0 version and is up to date.
✔ Component tns-android has 6.5.0 version and is up to date.
✔ Component tns-ios has 6.5.0 version and is up to date.
这似乎是 NativeScript-Vue 当前版本(截至今天,v2.5.0)的问题。每次您尝试创建模态时,它都会尝试使用相同的父控制器,使用第一个模态作为第二个模态的父级将解决问题。但是没有解决方法,要么您必须完全自己处理模态,要么对 nativescript-vue 包的源代码进行修补。否则,您可以使用解决此特定问题的 v2.3.0(但我不确定您在 v2.5.0 上还有哪些其他好处,您可能需要查看更改日志)。
我建议你在 Github repo 上用你的 Playground 示例提出问题并 link 到这个 SO post,希望他们在下一个版本中修复它。
nativescript-vue 文档不清楚如何使用嵌套模式,因为它在@yukashima-huksay 的 post 之后被修复。但是github上有an example演示了它的用法。
可以使用 target
选项打开辅助模式,它可以针对当前视图(使用 this
)或元素(即 this.$refs[<some element>]
)。
// this
this.$showModal(SecondaryModal, { target: this });
// $refs
this.$showModal(SecondaryModal, { target: this.$refs['myView'] });