Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

vue组件调用问题 #29

Closed
xiaosatufu opened this issue Aug 6, 2019 · 3 comments
Closed

vue组件调用问题 #29

xiaosatufu opened this issue Aug 6, 2019 · 3 comments

Comments

@xiaosatufu
Copy link

dialog组件 的组件调用 在当前页面写了Vue.use(dialog) 不能使用,想请问一下这个全局注册怎么注册。下面这种组件调用的方式只能用于函数,不能用于dialog的组件调用(就是写在页面里,因为我要自定义内容)
import { Dialog } from "vant"; export default { components: { Dialog } }
image

找到官方的解释
image

请问怎么解决呢?

@grapewheel
Copy link
Owner

Dialog 是可以局部注册的,具体请看 文档

@xiaosatufu
Copy link
Author

我知道可以局部注册,我说的是dialog组件 组件调用 的应用场景。

@grapewheel
Copy link
Owner

grapewheel commented Aug 9, 2019

// 如果需要在弹窗内嵌入组件或其他自定义内容,可以使用组件调用的方式

<van-dialog
  v-model="show"
  title="标题"
  show-cancel-button
>
  <img src="https://img.yzcdn.cn/vant/apple-3.jpg">
</van-dialog>

export default {
  data() {
    return {
      show: false
    };
  }
}

试下局部注册后,如上使用

export default {
  components: {
    'van-dialog': Dialog.Component
  }
}

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

No branches or pull requests

2 participants