Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用vuex 控制popup visible的问题 #403

Closed
zppro opened this issue Nov 1, 2016 · 3 comments
Closed

使用vuex 控制popup visible的问题 #403

zppro opened this issue Nov 1, 2016 · 3 comments
Labels

Comments

@zppro
Copy link

zppro commented Nov 1, 2016

使用vue2.0 ,mint-ui 2.0.2

没有用本地变量而是用了一个vuex中的状态变量来控制popup的隐藏显示,并设置model=true,closeOnClickModal=true 点击model层不会关闭popup,但是会关闭model层(灰色的mask)
也没有找到关闭model的hook
希望能提供api
或者给出使用vuex控制popup的例子

@Leopoldthecoder
Copy link
Contributor

试试直接调用 popup 实例的 close 方法。比如:

<mt-popup ref="popup">...</mt-popup>

则可以

this.$refs.popup.close()

@zppro
Copy link
Author

zppro commented Nov 11, 2016

data () {
      return {
        localLeftPopupVisible: false
      }
    },
    computed: {
      ...mapState(['routerTransiting', 'routerTransitValue', 'routerTransitHeight', 'leftPopupVisible']),
      ...mapGetters(['isLogined'])
    },
    watch: {
      leftPopupVisible: function (newLeftPopupVisible) {
        this.localLeftPopupVisible = newLeftPopupVisible
      },
      localLeftPopupVisible: function (newLocalLeftPopupVisible) {
        !newLocalLeftPopupVisible && this[$GLOABL_PREFIX$ + HIDE_LEFT_POPUP]()
      }
    },

后来用了watch来实现
文档里最好把这些api公布出来

@zppro zppro closed this as completed Nov 11, 2016
@NickBoomBoom
Copy link

这是这个问题的详细解答,还包括了另一个存在的问题的解决方案
https://nick-qi.github.io/2017/09/07/%E5%85%B3%E4%BA%8Emint-ui%E7%9A%84popup%E6%A8%A1%E6%80%81%E6%A1%86%E7%9A%84bug/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants