# Toast
API 示意
this.$toast(`内容内容内容`, {
autoClose: false, // 是否自动关闭,默认 false
closeDelay: 2, // 自动关闭时间,单位“秒”,默认 2s
position: 'top', // 弹出位置,默认顶部
closeButton: { // 关闭按钮
text: '关闭', // 关闭按钮文本
callback(toast) { // 关闭按钮回调,toast 为组件实例对象
toast.log() // 可调用组件内部的方法
}
}
})
设置弹出位置
<g-button @click="showToast('top')">top</g-button>
<g-button @click="showToast('middle')">middle</g-button>
<g-button @click="showToast('bottom')">bottom</g-button>
showToast(position) {
this.$toast('内容内容内容', {
autoClose: true,
closeDelay: 2,
position,
closeButton: {
text: '关闭',
callback(toast) {
toast.log()
}
}
})
},← Layout - 布局 Tabs - 标签 →