【问题标题】:Vue Launch Modal with Message带有消息的 Vue 启动模式
【发布时间】:2019-03-15 17:43:33
【问题描述】:

我正在尝试启动一个模态窗口,就像普通的 alert() 一样

我正在使用 bootstrap-vue BModal

  1. 如何从代码生成 Modal 类并启动它
  2. 或者,在根 app.vue 中添加 modal 并从子类中调用它。

我找到了一个示例,但无法复制 - https://codesandbox.io/embed/4l3w20zomw

【问题讨论】:

    标签: vue.js bootstrap-vue


    【解决方案1】:

    我认为你需要使用show()hide()toggle()组件方法,这里是Link,但是这里的区别你将调用show()方法到mounted()钩子它会调用showModal方法在挂载周期中,因此当托管应用程序时,您会看到类似警报的模式,例如

    <template>
      <div>
        <b-modal ref="myModalRef" hide-footer title="Using Component Methods">
          <div class="d-block text-center">
            <h1>Any Content here</h1>
          </div>
        </b-modal>
      </div>
    </template>
    
    <script>
      export default {
        methods: {
          showModal() {
            this.$refs.myModalRef.show()
          },
          hideModal() {
            this.$refs.myModalRef.hide()
          }
        },
        mounted() {
         this.showModal();
        }
      }
    </script>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-27
      • 2018-05-07
      • 1970-01-01
      • 2016-11-03
      • 2013-10-20
      • 2022-01-08
      • 2014-09-22
      • 2019-01-28
      相关资源
      最近更新 更多