无法在 Vuejs 中使用 vue-bootstrap 的 $bvModal 动态渲染模态

was_777

我想动态呈现 vue-bootstrap 的模式,而不是通过编写任何 html 代码。我参考了文档 - https://bootstrap-vue.js.org/docs/components/modal/#modal-message-boxes并在我的 vue 项目中应用了相同的内容,但是当我尝试调用时它给了我一个错误bvModal.msgBoxOk('sad') -

vue.runtime.esm.js?ff9b:587 [Vue warn]: Property or method "$bvModal" 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://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties

我在 jsfiddle 和它的工作中尝试过它,但它在我的项目中不起作用 - https://jsfiddle.net/yrb4tcfm/11/

这是我的 main.js

    import 'babel-polyfill'
    import Vue from 'vue'
    import App from './App'
    import router from './router'
    import BootstrapVue from 'bootstrap-vue'
    import store from './store/store'
    import 'bootstrap/dist/css/bootstrap.css'
    import 'bootstrap-vue/dist/bootstrap-vue.css'
    import Modal from 'bootstrap-vue/es/components/modal'


    Vue.use(BootstrapVue)
    Vue.use(Modal)

    new Vue({
      el: '#app',
      store,
      router,
      render: h => h(App)
    })

以前,我尝试不添加 Vue.use(Modal),因为我已经在使用 BootstrapVue 插件,但仍然无法正常工作。

应用程序视图

    <template>
      <b-btn @click="show()">Hello</b-btn>
    </template>

    <script>
    export default {
      methods: {
        show: function () {
          this.$bvModal.msgBoxOk('fdsdfds')
        }
      }
    }
    </script>

包.json

    {
      "name": "xyz",
      "version": "1.0.0",
      "description": "xyz",
      "author": "xyz",
      "private": false,
      "scripts": {
        "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
        "dev:admin": "webpack-dev-server --inline --progress --config build/webpack.dev.admin.conf.js",
        "dev:user": "webpack-dev-server --inline --progress --config build/webpack.dev.user.conf.js",
        "local:admin": "webpack-dev-server --inline --progress --config build/webpack.local.admin.conf.js",
        "local:user": "webpack-dev-server --inline --progress --config build/webpack.local.user.conf.js",
        "dev:gen": "node generators/generate.js",
        "start": "npm run dev",
        "unit": "jest --config test/unit/jest.conf.js --coverage --silent",
        "e2e": "node test/e2e/runner.js",
        "local:e2e": "node test/e2e/runner-local-e2e.js --port",
        "cypress:open": "cypress open",
        "cypress:run": "cypress run",
        "test": "jest --clearCache && npm run unit && npm run e2e",
        "lint": "eslint --ext .js,.vue src test/unit test/e2e/specs",
        "clear_jest": "jest --clearCache",
        "build": "node build/build.js"
      },
      "dependencies": {
        "bootstrap-vue": "2.0.0-rc.11",
        "lodash": "4.17.11",
        "moment": "2.22.2",
        "stylus": "0.54.5",
        "stylus-loader": "3.0.2",
        "vue": "2.5.16",
        "vue-router": "3.0.1",
        "vuex": "3.0.1",
        "whatwg-fetch": "2.0.4"
      },
      "devDependencies": {
        "@vue/test-utils": "1.0.0-beta.19",
        "autoprefixer": "7.2.6",
        "babel-core": "6.26.3",
        "babel-eslint": "8.2.3",
        "babel-helper-vue-jsx-merge-props": "2.0.3",
        "babel-jest": "21.2.0",
        "babel-loader": "7.1.4",
        "babel-plugin-dynamic-import-node": "1.2.0",
        "babel-plugin-syntax-jsx": "6.18.0",
        "babel-plugin-transform-es2015-modules-commonjs": "6.26.2",
        "babel-plugin-transform-runtime": "6.23.0",
        "babel-plugin-transform-vue-jsx": "3.7.0",
        "babel-polyfill": "6.26.0",
        "babel-preset-env": "1.7.0",
        "babel-preset-stage-2": "6.24.1",
        "babel-register": "6.26.0",
        "chalk": "2.4.1",
        "chromedriver": "2.40.0",
        "copy-webpack-plugin": "4.5.1",
        "cross-spawn": "5.1.0",
        "css-loader": "0.28.11",
        "cypress": "3.0.2",
        "eslint": "4.19.1",
        "eslint-config-standard": "10.2.1",
        "eslint-friendly-formatter": "3.0.0",
        "eslint-loader": "1.9.0",
        "eslint-plugin-cypress": "2.0.1",
        "eslint-plugin-import": "2.12.0",
        "eslint-plugin-node": "5.2.1",
        "eslint-plugin-promise": "3.8.0",
        "eslint-plugin-standard": "3.1.0",
        "eslint-plugin-vue": "4.5.0",
        "extract-text-webpack-plugin": "3.0.2",
        "fetch-mock": "6.5.0",
        "file-loader": "1.1.11",
        "friendly-errors-webpack-plugin": "1.7.0",
        "geckodriver": "1.12.2",
        "html-webpack-plugin": "2.30.1",
        "jest": "22.4.4",
        "jest-serializer-vue": "0.3.0",
        "nightwatch": "0.9.21",
        "node-notifier": "5.2.1",
        "node-sass": "4.9.3",
        "optimize-css-assets-webpack-plugin": "3.2.0",
        "ora": "0.2.3",
        "portfinder": "1.0.13",
        "postcss-import": "11.1.0",
        "postcss-loader": "2.1.5",
        "postcss-url": "7.3.2",
        "rimraf": "2.6.2",
        "sass-loader": "7.1.0",
        "selenium-server": "3.12.0",
        "semver": "5.5.0",
        "shelljs": "0.7.8",
        "uglifyjs-webpack-plugin": "1.2.5",
        "url-loader": "0.5.9",
        "vue-jest": "1.4.0",
        "vue-loader": "13.7.2",
        "vue-style-loader": "3.1.2",
        "vue-template-compiler": "2.5.16",
        "vue2-datepicker": "2.5.0",
        "webpack": "3.12.0",
        "webpack-bundle-analyzer": "2.13.1",
        "webpack-dev-server": "2.11.2",
        "webpack-merge": "4.1.3"
      },
      "engines": {
        "node": ">= 6.0.0",
        "npm": ">= 3.0.0"
      },
      "browserslist": [
        "> 1%",
        "last 2 versions",
        "not ie <= 8"
      ]
    }
费利佩布拉加

您可以将bootstrap-vue更新到最新版本2.0.0-rc.19它为我解决了问题。

发行说明

https://github.com/bootstrap-vue/bootstrap-vue/releases/tag/v2.0.0-rc.19

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

无法在VueJs中使用V-for渲染列表

来自分类Dev

无法使用VueJS渲染图像

来自分类Dev

未捕获的TypeError:无法读取未定义vue的属性'$ bvModal'

来自分类Dev

如何使用 Bootstrap-vue 在 VueJS 中滚动标签

来自分类Dev

VueJS组件无法与Bootstrap表一起使用

来自分类Dev

VueJS组件无法与Bootstrap表一起使用

来自分类Dev

在vue-socket-io中使用vuejs

来自分类Dev

无法使用 Bootstrap 3.3.7 使模态工作

来自分类Dev

(VueJs)我无法在vuejs中使用方法吗?

来自分类Dev

Bootstrap-Vue动态吐司无法正常工作

来自分类Dev

Vue JS-使用innerHTML渲染的动态创建的组件无法绑定到事件

来自分类Dev

VueJs [Vue警告]:渲染错误:“ TypeError:无法读取未定义的属性'title'”

来自分类Dev

如何在Vue组件中使用Bootstrap?

来自分类Dev

在Vue 3中使用Bootstrap 5

来自分类Dev

如何在Vue中使用Bootstrap

来自分类Dev

Vue和Bootstrap Vue-动态使用插槽

来自分类Dev

Bootstrap Datepicker无法在Chrome中使用

来自分类Dev

在不带Webpack的情况下使用vuejs 3执行bootstrap vue组件

来自分类Dev

在 vue typescript 项目中使用 vuejs 组件

来自分类Dev

无法在Vue 3中使用Vuex

来自分类Dev

Bootstrap 模态隐藏 VUE 方法

来自分类Dev

无法在Vue和Vuetify的动态内容中渲染图像源

来自分类Dev

VUEJS无法在模板中使用api响应数据

来自分类Dev

如何在模态中使用VueJS复制当前行的数据?

来自分类Dev

无法从Bootstrap加载示例模态

来自分类Dev

VueJS vue-router 不渲染参数

来自分类Dev

一些vue bootstrap-vue图标无法与nuxt一起使用

来自分类Dev

动态输出Bootstrap模态

来自分类Dev

VueJS显示动态模态组件