我有以下HTML代码:
<html>
<title> Reddit </title>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-beta.20/css/uikit.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-beta.20/js/uikit.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-beta.20/js/uikit-icons.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/2.27.2/js/core/modal.min.js"></script>
</head>
<body>
<button class="md-btn md-btn-success" data-uk-modal="{target:'#my_id'}">Open
Dialogue</button>
<div class="uk-modal" id="my_id" >
<div class="uk-modal-dialog">
<div class="uk-modal-header">
Custom Content here
</div>
</div>
<div class="uk-modal-footer uk-text-right">
<button type="button" class="md-btn md-btn-flat uk-modal-
close">Close</button>
</div>
</div>
</body>
</html>
我通过getuikit cdn链接加载uikit组件。但是根本不显示模态窗口。我不知道我是否正确包含了一切。请帮忙。
答案 0 :(得分:1)
代码中的一些问题:
data-uk-modal="{target:'#my_id'}"
,而是将其更改为uk-toggle="target: #my_id"
uk-modal
添加到实际模态div(即<div class="uk-modal" id="my_id" uk-modal>
)uk-modal-footer
div放在uk-modal-dialog
div。完整代码:
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-beta.20/css/uikit.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-beta.20/js/uikit.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-beta.20/js/uikit-icons.min.js"></script>
</head>
<body>
<button class="md-btn md-btn-success" uk-toggle="target: #my_id">Open Dialogue</button>
<div class="uk-modal" id="my_id" uk-modal>
<div class="uk-modal-dialog">
<div class="uk-modal-header">
Custom Content here
</div>
<div class="uk-modal-footer uk-text-right">
<button type="button" class="md-btn md-btn-flat uk-modal-close">Close</button>
</div>
</div>
</div>
</body>
</html>
旁注:您也在混合使用Bootstrap类,通常只关注一个前端框架。