Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
332 views
in Technique[技术] by (71.8m points)

snackbar - 基本的Snackbar示例未在Web的材料设计组件上显示(Basic Snackbar Example doesn't show on Material Design Components for Web)

The basic example of snackbar for Material Design Components for Web doesn't work.

(Web的Material Design组件的快餐栏的基本示例不起作用。)

It produces the error:

(它产生错误:)

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

I have tried using jQuery to make sure the DOM loaded properly.

(我尝试使用jQuery确保DOM正确加载。)

I have tried changing back and forth the javascript initialisation methods, but none seems to work.

(我尝试来回更改javascript初始化方法,但似乎没有任何效果。)

You can find the code here: https://jsbin.com/mejefeq/edit?html,console,output

(您可以在这里找到代码: https : //jsbin.com/mejefeq/edit?html,控制台,输出)

I have read the docs over and overs again, but none of it mentioned anything about this.

(我一遍又一遍地阅读了文档,但是都没有提及任何内容。)

Since this MDC for Web is not at all popular, I have nowhere left to go for help.

(由于此MDC for Web根本不受欢迎,因此我无处可去寻求帮助。)

  ask by user3622260 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Yeah that was a breaking change in the 0.43.0 update .

(是的,这是0.43.0更新中的重大更改。)

The new way of showing the snackbar is by using

(显示小吃店的新方法是使用)

snackbar.open();

This however will just open the snackbar.

(但是,这只会打开小吃店。)

If you want to change the text in the snackbar you can use:

(如果要更改小吃栏中的文本,可以使用:)

snackbar.labelText = 'Your new text';

So together you can use them:

(因此,您可以一起使用它们:)

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

You can check out more of the documentation here , with the current javascript properties and events here

(您可以在此处查看更多文档,并在此处获取当前的javascript属性和事件)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...