javascript - bootboxjs 无效的提示类型 - 文档中的示例不起作用

标签 javascript twitter-bootstrap bootstrap-4 bootstrap-modal bootbox

我正在尝试使用http://bootboxjs.com/examples.html#bb-prompt在我的项目中,所以很自然地我开始使用他们的示例代码来查看它是否运行。

根据文档;我正在使用最新的 bootstrap、jquery 和 bootstrap js,然后加载 bootboxjs。这是我尝试运行的代码:

bootbox.prompt({
    title: "This is a prompt with a set of radio inputs!",
    message: '<p>Please select an option below:</p>',
    inputType: 'radio',
    inputOptions: [
    {
        text: 'Choice One',
        value: '1',
    },
    {
        text: 'Choice Two',
        value: '2',
    },
    {
        text: 'Choice Three',
        value: '3',
    }
    ],
    callback: function (result) {
        console.log(result);
    }
});

当这段代码执行时;我收到此错误:

Uncaught Error: invalid prompt type

enter image description here

这是一个非常好的库,我很乐意在我的项目中使用它;但我有点难住了。有什么想法吗?

最佳答案

我已经解决了这个问题。我最初只使用了 bootbox.min.js,但事实证明我还需要使用 bootbox.locales.min.js。我应该有 rtfm...

此外,我使用 webpack(通过 laravel-mix)将所有库捆绑到一个 .js 文件中,因此使用 bootbox.all.min.js (使用区域设置的生产构建)作为我加载的最后一件事似乎也有帮助。

这是我的 webpack.mix.js 配置文件,适用于我:

const mix = require('laravel-mix');

mix
    .copyDirectory('resources/libs/font-awesome/fonts', 'public/fonts')
    .styles(
        [
            // snipped...
        ],
        'public/css/app.css'
    )
    .scripts(
        [
            'resources/libs/jquery/jquery-3.4.1.min.js',
            'resources/libs/bootstrap/bootstrap.bundle.min.js',
            // bunch of other js libs...
            'resources/libs/bootbox/bootbox.all.min.js',
        ],
        'public/js/app.js'
    );

关于javascript - bootboxjs 无效的提示类型 - 文档中的示例不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57236720/

相关文章:

javascript - Pixi.js 绘制下落的方 block

javascript - mootools/class/objectinstance 不起作用

javascript - 如何在不重新加载页面的情况下显示模式

javascript - div 高度和宽度在旋转木马 slider 中不固定

css - 对齐内容不工作 Internet Explorer 11

html - Bootstrap Carousel 和 <img> 标签与 object-fit & object-position 不工作

sass - 找不到要导入的样式表

javascript - Gulp "watch"为外部 API 提供代理

javascript - jQuery 鼠标悬停事件处理程序不工作或被检测到

html - 移动导航栏的问题