如何在Electron中显示Bootstrap模态框?

huangapple go评论98阅读模式
英文:

How to display Bootstrap modal in Electron?

问题

尝试在Electron中显示Bootstrap模态框。

我已安装了jquery和bootstrap模块。
然后在.js文件中编写了以下代码。

const $ = require('jquery');
require('bootstrap');

$(document).ready(() => {
  $('#myModal').modal();
});

当然,在.html文件中有一个id为myModal的

标签。
然而,运行时出现以下错误。

$(...).modal 不是一个函数。

原因是什么,如何实现它?

英文:

Trying to display Bootstrap Modal in electron.

I have installed jquery and bootstrap modules.
Then wrote following code in .js file.

const $ = require('jquery');
require('bootstrap');

$(document).ready(() => {
  $('#myModal').modal();
});

Of course, there is Div tag with id=myModal in .html file.
However, when running, the following error is displayed.

$(...).modal is not a function.

What is the reason and how to implement it?

答案1

得分: 0

我在之前的ElectronJS中遇到了Bootstrap模态窗口的问题。使用以下代码时,它可以正常工作。

var myModal = new bootstrap.Modal(document.getElementById('myModal'), options)
英文:

Try please your app with this code

var myModal = new bootstrap.Modal(document.getElementById('myModal'), options)

I met Bootstrap modal issue in ElectronJS in before.
It was work well with this code.

huangapple
  • 本文由 发表于 2023年8月5日 10:00:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/76839870.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定