zdhxiong / mdui

Material Design 3(Material You) UI components using Web Components.
https://www.mdui.org
4.19k stars 365 forks source link

Uncaught (in promise) TypeError: Failed to execute 'animate' on 'Element': duration must be non-negative or auto #354

Closed yexiaoyu123 closed 1 month ago

yexiaoyu123 commented 1 month ago

dialog包含文本框并设置前后图标时控制台会报错 Uncaught (in promise) TypeError: Failed to execute 'animate' on 'Element': duration must be non-negative or auto Screenshot_6

代码: Screenshot_7

zdhxiong commented 1 month ago

把代码贴出来

yexiaoyu123 commented 1 month ago

把代码贴出来

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Test</title>
    <link rel="stylesheet" href="https://unpkg.com/mdui@2/mdui.css">
    <script src="https://unpkg.com/mdui@2/mdui.global.js"></script>
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <!-- Outlined -->
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons+Outlined" rel="stylesheet">
    <!-- Rounded -->
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons+Round" rel="stylesheet">
    <!-- Sharp -->
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons+Sharp" rel="stylesheet">
    <!-- Two Tone -->
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons+Two+Tone" rel="stylesheet">
</head>
<body>
    <mdui-dialog class="example-dialog">
        Dialog
        <mdui-text-field label="Text Field">
            <mdui-button-icon slot="icon" icon="search"></mdui-button-icon>
            <mdui-button-icon slot="end-icon" icon="mic"></mdui-button-icon>
        </mdui-text-field>
        <mdui-button>关闭</mdui-button>
    </mdui-dialog>
    <mdui-button>打开对话框</mdui-button>

<script>
  const dialog = document.querySelector(".example-dialog");
  const openButton = dialog.nextElementSibling;
  const closeButton = dialog.querySelector("mdui-button");
  openButton.addEventListener("click", () => dialog.open = true);
  closeButton.addEventListener("click", () => dialog.open = false);
</script>
</body>
</html>