1

Here's my code (ERROR):

<template lang="pug">
  .component-root
    b-btn(v-b-modal.myModal)
      i.fa.fa-calendar
    b-modal#myModal
      span Hello this is my modal!
</template>

it outputs an error message:

[Vue warn]: Property or method "v" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

When I use $refs method to create modal, it works :

<template lang="pug">
  b-button(@click="showModal")
    i.fa.fa-calendar
  b-modal(ref="myModalRef" hide-footer title="some title")
    span Hello form my modal
</template>

<script>
  ...
  methods: {
    showModal() {
      this.$refs.myModalRef.show();
    },
  }
  ...
</script>

Here's my main App.js with BootstrapVue installed

import 'bootstrap-vue/dist/bootstrap-vue.css';
import 'font-awesome/css/font-awesome.min.css';

import Vue from 'vue';
import Moment from 'vue-moment';
import BootstrapVue from 'bootstrap-vue';
import DatePicker from 'vue2-datepicker';

import './assets/bootstrap.cosmo.min.css';

import App from './App';
import router from './router';

Vue.config.productionTip = false;
Vue.use(BootstrapVue);
Vue.use(Moment);
Vue.use(DatePicker);

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>',
});

I just following the manual here: https://bootstrap-vue.js.org/docs/components/modal/ So far I have problem until I want to show some modal.

What's wrong with me?

3
  • Do you know what v is that? Does that pug template renders any attribute with a v value in it? Commented Mar 6, 2018 at 4:03
  • @Bhojendra: What? how is it a duplicate to that ??? It's in asp.net and it has no reference to any BootstrapVue modal at all. Commented Mar 6, 2018 at 4:04
  • @acdcjunior : I just following this manual from BootstrapVue's own website bootstrap-vue.js.org/docs/components/modal Commented Mar 6, 2018 at 4:05

1 Answer 1

1

The problem is pug. In:

<template lang="pug">
  .component-root
    b-btn(v-b-modal.myModal)
      i.fa.fa-calendar
    b-modal#myModal
      span Hello this is my modal!
</template>

The line:

b-btn(v-b-modal.myModal)

Messes things up. Use:

b-btn(v-b-modal.myModal="")

Reason:

b-btn(v-b-modal.myModal) creates <b-btn v-b-modal.myModal="v-b-modal.myModal">, which makes Vue search for that falue. Using b-btn(v-b-modal.myModal="") creates <b-btn v-b-modal.myModal=""> which solves the problem.

More: https://github.com/pugjs/pug/issues/370#issuecomment-2399051

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.