使用google组件,这里显示的是快餐店消息,但没有显示actionText。如果您想显示示例和detail 关于
<!DOCTYPE html>
<html class="mdc-typography">
<head>
<title>Material Components for the web</title>
<link rel="stylesheet"
href="node_modules/material-components-web/dist/material-components-web.css">
<meta name="viewport" content="width=device-width">
<script src="main.js" charset="utf-8"></script>
</head>
<body>
<div class="mdc-snackbar mdc-snackbar--align-start"
aria-live="assertive"
aria-atomic="true"
aria-hidden="true">
<div class="mdc-snackbar__text"></div>
<div class="mdc-snackbar__action-wrapper">
<button type="button" class="mdc-snackbar__action-button"></button>
</div`
</div>
<script src="node_modules/material-components-web/dist/material-components-web.js"></script>
<script>mdc.autoInit()</script>
<script>
var q=mdc.snackbar.MDCSnackbar.attachTo(document.querySelector('.mdc-snackbar'));
const data={
message: 'Message deleted',
actionText: 'Undo'
};
q.show(data);
</script>
</body>
</html>发布于 2017-10-31 07:38:56
如果您有actionHandler,则应该添加actionText
var q=mdc.snackbar.MDCSnackbar.attachTo(document.querySelector('.mdc-snackbar'));
const data={
message: 'Message deleted',
actionText: 'Undo',
actionHandler: function() {
console.log(data);
}
};
q.show(data);<script src="https://material-components-web.appspot.com/assets/material-components-web.js"></script>
<!DOCTYPE html>
<html class="mdc-typography">
<head>
<title>Material Components for the web</title>
<link rel="stylesheet"
href="node_modules/material-components-web/dist/material-components-web.css">
<meta name="viewport" content="width=device-width">
<script src="main.js" charset="utf-8"></script>
</head>
<body>
<div class="mdc-snackbar mdc-snackbar--align-start"
aria-live="assertive"
aria-atomic="true"
aria-hidden="true">
<div class="mdc-snackbar__text"></div>
<div class="mdc-snackbar__action-wrapper">
<button type="button" class="mdc-snackbar__action-button"></button>
</div>
</div>
<script>mdc.autoInit()</script>
</body>
</html>
https://stackoverflow.com/questions/47028846
复制相似问题