【问题标题】:Basic Snackbar Example doesn't show on Material Design Components for Web基本 Snackbar 示例未显示在 Material Design Components for Web
【发布时间】:2019-12-26 09:30:10
【问题描述】:

Material Design Components for Web 的快餐栏基本示例不起作用。它会产生错误:

```
TypeError: snackbar.show is not a function
```

我尝试使用 jQuery 来确保 DOM 正确加载。我曾尝试来回更改 javascript 初始化方法,但似乎都没有。

您可以在这里找到代码:https://jsbin.com/mejefeq/edit?html,console,output

我已经一遍又一遍地阅读文档,但没有一个提到任何关于此的内容。由于这个 MDC for Web 一点也不流行,我无处可去寻求帮助。

【问题讨论】:

  • 你试过运行snackbar.open() 吗?这将在 Snackbar 正文中显示 DOM 文本内容。如果你想改变它使用snackbar.labelText('New text')。更多关于 here

标签: snackbar mdc-components


【解决方案1】:

是的,这是0.43.0 update 中的重大更改。显示snackbar 的新方法是使用

snackbar.open();

不过,这只会打开小吃吧。如果您想更改小吃栏中的文本,您可以使用:

snackbar.labelText = 'Your new text';

所以你可以一起使用它们:

snackbar.labelText = 'Your new text';
snackbar.open();

您可以查看更多文档 here,以及当前的 javascript 属性和事件 here

【讨论】:

    猜你喜欢
    • 2021-02-20
    • 2019-04-16
    • 2019-08-24
    • 2017-10-22
    • 2019-09-27
    • 1970-01-01
    • 2017-02-23
    • 2019-02-09
    • 2019-02-22
    相关资源
    最近更新 更多